/** * Default backend base URL — the operator-set fallback used when no specific * instance is active. Resolution order: * * 1. window.__APP_CONFIG__.apiBaseUrl — runtime, injected by the container * at start from $PUBLIC_API_BASE_URL (see public/config.js). Lets one * prebuilt image point at any backend origin without rebuilding. * 2. import.meta.env.PUBLIC_API_BASE_URL — build-time default (rsbuild inlines * PUBLIC_* vars). Used in local dev and as a baked fallback. * 3. '/api/v1' — same-origin relative path (works behind a reverse proxy). * * The user's chosen instance still wins over all of these — see * runtime-config.ts / instances.ts. */ function runtimeApiBaseUrl(): string | undefined { if (typeof window === 'undefined') return undefined; const value = window.__APP_CONFIG__?.apiBaseUrl; return value ? value : undefined; } export const DEFAULT_API_BASE_URL = runtimeApiBaseUrl() ?? import.meta.env.PUBLIC_API_BASE_URL ?? '/api/v1';