Files
multica/apps/web/config/runtime-urls.ts
YOMXXX bfb7c85491 fix(selfhost): derive local port URLs from env (MUL-2506) (#2939)
* fix(selfhost): derive local port URLs from env

* fix(selfhost): derive local script URLs
2026-05-24 13:05:53 +08:00

19 lines
518 B
TypeScript

type RuntimeEnv = Record<string, string | undefined>;
export function resolveRemoteApiUrl(env: RuntimeEnv): string {
const explicitRemote = env.REMOTE_API_URL?.trim();
if (explicitRemote) return explicitRemote;
const publicApi = env.NEXT_PUBLIC_API_URL?.trim();
if (publicApi) return publicApi;
const port =
env.BACKEND_PORT?.trim() ||
env.API_PORT?.trim() ||
env.SERVER_PORT?.trim() ||
env.PORT?.trim();
if (port) return `http://localhost:${port}`;
return "http://localhost:8080";
}