From 1eb3da814dce38cc801771dde6e6648b1d031d9d Mon Sep 17 00:00:00 2001 From: Tiago Yamamoto Date: Wed, 31 Dec 2025 09:56:01 -0300 Subject: [PATCH] fix(frontend): block access until runtime config is loaded --- frontend/src/contexts/ConfigContext.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/src/contexts/ConfigContext.tsx b/frontend/src/contexts/ConfigContext.tsx index a64791b..63e1e91 100644 --- a/frontend/src/contexts/ConfigContext.tsx +++ b/frontend/src/contexts/ConfigContext.tsx @@ -36,7 +36,10 @@ export function ConfigProvider({ children }: { children: ReactNode }) { const response = await fetch('/api/config'); if (response.ok) { const data = await response.json(); + console.log('[Config] Loaded runtime config:', data); setConfig(data); + // Also update the global cached config for non-React usage + cachedConfig = data; } } catch (error) { console.warn('[Config] Failed to fetch runtime config, using defaults:', error); @@ -48,6 +51,14 @@ export function ConfigProvider({ children }: { children: ReactNode }) { fetchConfig(); }, []); + if (isLoading) { + return ( +
+
+
+ ); + } + return ( {children} @@ -70,7 +81,7 @@ let cachedConfig: RuntimeConfig | null = null; export async function getConfig(): Promise { if (cachedConfig) return cachedConfig; - + try { const response = await fetch('/api/config'); if (response.ok) { @@ -80,7 +91,7 @@ export async function getConfig(): Promise { } catch { console.warn('[Config] Failed to fetch config, using defaults'); } - + return defaultConfig; }