20 lines
807 B
TypeScript
20 lines
807 B
TypeScript
declare global {
|
|
interface Window {
|
|
INOGEN_CONFIG?: { apiBaseUrl?: string };
|
|
}
|
|
}
|
|
|
|
const runtimeApiUrl = typeof window !== "undefined"
|
|
? window.INOGEN_CONFIG?.apiBaseUrl?.trim()
|
|
: undefined;
|
|
const buildApiUrl = (import.meta.env.VITE_API_URL as string | undefined)?.trim();
|
|
const configuredApiUrl = import.meta.env.DEV
|
|
? buildApiUrl || runtimeApiUrl
|
|
: runtimeApiUrl || buildApiUrl;
|
|
|
|
// The runtime value is loaded before the application bundle, so a deployment can
|
|
// change the API endpoint without rebuilding the frontend. During development,
|
|
// VITE_API_URL remains authoritative so the API can run on its own local port.
|
|
export const API_BASE_URL = (configuredApiUrl || "/api/v1").replace(/\/$/, "");
|
|
export const API_ORIGIN = API_BASE_URL.replace(/\/api\/v1\/?$/, "").replace(/\/$/, "");
|