Files
thebet365/scripts/resolve-dev-api-target.mjs
Mars ce84226219 feat(admin+api): 代理停用默认、结算加固与冒烟配置探针
- 代理层级默认授信比例与停用冻结/禁登全局默认

- 结算预览去重、比分校验、串关当场判负与市场类型校验

- 站内信 Banner/公告自动通知开关;开发环境动态 API 端口

- 扩充 RBAC/结算/认证/返现单元测试与 agent skills
2026-06-23 11:08:41 +08:00

18 lines
666 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { existsSync, readFileSync } from 'node:fs';
import { resolve, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const envPath = resolve(root, 'apps/api/.env');
/** 读取 apps/api/.env 的 PORT供 Vite 代理与 dev 脚本共用 */
export function resolveDevApiPort(fallback = '3000') {
if (!existsSync(envPath)) return fallback;
const match = readFileSync(envPath, 'utf8').match(/^PORT=(\d+)/m);
return match?.[1] ?? fallback;
}
export function resolveDevApiTarget(fallbackPort = '3000') {
return `http://127.0.0.1:${resolveDevApiPort(fallbackPort)}`;
}