Description
gql() in frontend/src/api/graphql.ts calls await res.json() without
checking res.ok first. If the server returns a 401/500 with an HTML error
page, res.json() throws an opaque SyntaxError instead of a useful API error.
Fix
- Read response as
text first, then attempt JSON.parse in a try/catch
- Check
res.ok before accessing response data
- Surface HTTP status and body preview in thrown errors
Frontend-only change. File affected: frontend/src/api/graphql.ts
Description
gql()infrontend/src/api/graphql.tscallsawait res.json()withoutchecking
res.okfirst. If the server returns a 401/500 with an HTML errorpage,
res.json()throws an opaqueSyntaxErrorinstead of a useful API error.Fix
textfirst, then attemptJSON.parsein atry/catchres.okbefore accessing response dataFrontend-only change. File affected:
frontend/src/api/graphql.ts