interface AppConfig { logtoEndpoint: string; logtoClientId: string; } let cached: AppConfig | null = null; export async function fetchConfig(): Promise { if (cached) return cached; try { const response = await fetch('/api/config'); if (response.ok) { cached = await response.json(); return cached!; } } catch { // Config endpoint not available (e.g., Vite dev without backend) } // Fallback to env vars (Vite dev mode) cached = { logtoEndpoint: import.meta.env.VITE_LOGTO_ENDPOINT || 'http://localhost:3001', logtoClientId: import.meta.env.VITE_LOGTO_CLIENT_ID || '', }; return cached; }