fix(player): dev Vite proxy reads API PORT; wallet list rows blend with page background
This commit is contained in:
19
scripts/dev-api-target.mjs
Normal file
19
scripts/dev-api-target.mjs
Normal file
@@ -0,0 +1,19 @@
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
|
||||
/** 本地 dev:与 apps/api/.env 的 PORT 对齐,供 player/admin Vite 代理使用 */
|
||||
export function resolveApiDevTarget() {
|
||||
if (process.env.VITE_DEV_API_TARGET) return process.env.VITE_DEV_API_TARGET;
|
||||
if (process.env.API_DEV_TARGET) return process.env.API_DEV_TARGET;
|
||||
|
||||
let port = '3000';
|
||||
const envPath = resolve(repoRoot, 'apps/api/.env');
|
||||
if (existsSync(envPath)) {
|
||||
const match = readFileSync(envPath, 'utf8').match(/^PORT=(\d+)\s*$/m);
|
||||
if (match) port = match[1];
|
||||
}
|
||||
return `http://localhost:${port}`;
|
||||
}
|
||||
Reference in New Issue
Block a user