{"record":{"id":"efd46b3357147f57","repo":"QuantumNous/new-api","slug":"failed-to-fetch-status","errorCode":null,"errorMessage":"Failed to fetch status","messagePattern":"Failed to fetch status","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"web/src/hooks/use-system-config.ts","lineNumber":108,"sourceCode":"      data.custom_currency_exchange_rate,\n      DEFAULT_CURRENCY_CONFIG.customCurrencyExchangeRate\n    ),\n  }\n\n  return {\n    systemName: data.system_name || DEFAULT_SYSTEM_NAME,\n    logo: data.logo || DEFAULT_LOGO,\n    footerHtml: data.footer_html,\n    demoSiteEnabled: data.demo_site_enabled,\n    displayTokenStatEnabled: data.display_token_stat_enabled,\n    currency,\n  }\n}\n\n// Fetch system config from API\nasync function fetchSystemConfig(): Promise<Partial<SystemConfig>> {\n  const response = await fetch('/api/status')\n  if (!response.ok) throw new Error('Failed to fetch status')\n\n  const data: StatusApiResponse = await response.json()\n  if (!data.success) throw new Error('API returned error')\n\n  return mapStatusDataToConfig(data.data)\n}\n\n// Preload image and return cleanup function\nfunction preloadImage(\n  src: string,\n  onLoad: () => void,\n  onError: () => void\n): () => void {\n  const img = new Image()\n  img.onload = onLoad\n  img.onerror = onError\n  img.src = src\n","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/QuantumNous/new-api/blob/e2c7aa7b102c2075eae2377df3508658d45e88dc/web/src/hooks/use-system-config.ts#L90-L126","documentation":"Thrown by fetchSystemConfig in use-system-config when the raw fetch of /api/status returns a non-2xx HTTP status (response.ok false). This is the pre-login status endpoint that supplies system name, logo, footer, and feature flags, so the whole app shell falls back to defaults when it fails. It is a transport-level failure, before any JSON success flag is evaluated.","triggerScenarios":"fetch('/api/status') resolves with a 4xx/5xx/3xx status: backend down, 502/503 from a proxy, 404 when the frontend is served without the /api proxy, 429 under rate limiting.","commonSituations":"Dev server started without the backend or with a wrong proxy configuration so /api/status 404s; gateway misrouting; backend crash during deploy; CDN serving the SPA while the API origin is unreachable.","solutions":["Open /api/status directly in the browser or curl it and read the HTTP status code.","If 404/502, fix the proxy config (Rsbuild dev proxy, nginx location /api, or base URL) so the SPA reaches the Go backend.","If 5xx, check backend logs/health — the status endpoint should be cheap; a 500 usually means startup misconfiguration.","Retry once on transient failures before falling back to default config values."],"exampleFix":"// before\nconst response = await fetch('/api/status')\nif (!response.ok) throw new Error('Failed to fetch status')\n\n// after — include status for diagnosability\nconst response = await fetch('/api/status')\nif (!response.ok) {\n  throw new Error(`Failed to fetch status: ${response.status} ${response.statusText}`)\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await fetchSystemConfig()\n} catch (error) {\n  if (error.message === 'Failed to fetch status') {\n    // fall back to DEFAULT_SYSTEM_NAME/DEFAULT_LOGO config; retry on next app focus\n  }\n}","preventionTips":["Verify the /api reverse-proxy rule in every environment before shipping the SPA","Treat /api/status failures as non-fatal: defaults must fully cover branding and flags","Add a health check for /api/status in deployment smoke tests"],"tags":["system-config","fetch","http-status","startup"],"backgroundTag":null,"analyzedSha":"e2c7aa7b102c2075eae2377df3508658d45e88dc","analyzedAt":"2026-08-15T10:35:18.111Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}