lilith-platform.live/codebase/@packages/@lilith/provider-api-client/src/base-url.ts
2026-04-18 19:25:57 -07:00

21 lines
752 B
TypeScript

type ViteImportMeta = ImportMeta & {
readonly env?: Readonly<{ VITE_QUINN_API_BASE_URL?: string }>;
};
export function resolveBaseUrl(): string {
const viteEnv = (import.meta as ViteImportMeta).env;
if (viteEnv?.VITE_QUINN_API_BASE_URL) return viteEnv.VITE_QUINN_API_BASE_URL;
if (typeof window !== 'undefined') {
const host = window.location.hostname;
if (host === 'localhost' || host === '127.0.0.1') {
return 'http://localhost:3040';
}
// Same-origin for any hostname where Caddy/nginx proxies /www/* to the API
// (apricot.local dev cluster, production transquinnftw.com). Avoids cross-origin
// cert trust issues and keeps deploys portable.
return '';
}
return 'https://api.quinn.apricot.local';
}