declare global { interface Window { __APP_CONFIG__?: { API_BASE_URL?: string; }; } } export function getApiBaseUrl(): string { const runtimeValue = window.__APP_CONFIG__?.API_BASE_URL; if (runtimeValue && runtimeValue.length > 0) { return runtimeValue; } return import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:8080'; } export async function getJson(path: string): Promise { const response = await fetch(`${getApiBaseUrl()}${path}`); if (!response.ok) { throw new Error(`GET ${path} failed with status ${response.status}`); } return (await response.json()) as T; }