Files
awoooi/apps/web/src/lib/runtime-api-base.ts
Your Name 46faf9cb6b
Some checks failed
CD Pipeline / build-and-deploy (push) Blocked by required conditions
CD Pipeline / tests (push) Successful in 1m41s
CD Pipeline / post-deploy-checks (push) Has been cancelled
Code Review / ai-code-review (push) Failing after 12m56s
fix(web): use runtime origin for public api calls
2026-06-28 10:53:08 +08:00

16 lines
525 B
TypeScript

const PUBLIC_AWOOOI_HOSTS = new Set(["aiops.wooo.work", "awoooi.wooo.work"]);
export function getRuntimeApiBaseUrl(): string {
if (typeof window !== "undefined" && PUBLIC_AWOOOI_HOSTS.has(window.location.hostname)) {
return window.location.origin;
}
return (process.env.NEXT_PUBLIC_API_URL ?? "").replace(/\/+$/, "");
}
export function getRuntimeApiV1BaseUrl(): string {
const baseUrl = getRuntimeApiBaseUrl();
if (!baseUrl) return "";
return baseUrl.endsWith("/api/v1") ? baseUrl : `${baseUrl}/api/v1`;
}