From 736fe40e75f69ee51630d182f16fd216d48fbc93 Mon Sep 17 00:00:00 2001 From: Heidi Date: Fri, 19 Jun 2026 23:58:50 +0100 Subject: [PATCH] ai generated solutions to our ai generated problems --- frontend/src/App.jsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 64e4f53..02d560a 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -94,7 +94,10 @@ async function fetchJson(path, signal) { signal, headers: { Accept: 'application/json' }, }) - const body = await response.json().catch(() => null) + const contentType = response.headers.get('content-type') || '' + const body = contentType.includes('application/json') + ? await response.json().catch(() => null) + : null if (!response.ok) { const error = new Error(body?.error || `Request failed with ${response.status}`) @@ -103,6 +106,14 @@ async function fetchJson(path, signal) { throw error } + if (!body) { + const error = new Error(`Expected JSON from ${path}`) + error.status = response.status + error.path = path + error.contentType = contentType + throw error + } + return body } @@ -115,7 +126,7 @@ async function fetchPublicJson(source, signal) { return await fetchJson(source.staticPath, signal) } catch (error) { if (signal?.aborted || error?.name === 'AbortError') throw error - if (error?.status === 404) missingStaticDataPaths.add(source.staticPath) + if (error?.status === 404 || error?.contentType) missingStaticDataPaths.add(source.staticPath) return fetchJson(source.apiPath, signal) } }