Skip to content

Commit

Permalink
Fix bug where JSON error response might get treated as non-JSON error…
Browse files Browse the repository at this point in the history
… response (#1407)
  • Loading branch information
Mtn-View authored Jan 8, 2025
1 parent 2608873 commit d7b30f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-insects-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'houdini': patch
---

Fix error bug JSON response might get treated as non-JSON if it includes `charset` or `boundary`
4 changes: 2 additions & 2 deletions packages/houdini/src/runtime/client/plugins/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ const defaultFetch = (
// Avoid parsing the response if it's not JSON, as that will throw a SyntaxError
if (
!result.ok &&
result.headers.get('content-type') !== 'application/json' &&
result.headers.get('content-type') !== 'application/graphql+json'
!result.headers.get('content-type')?.startsWith('application/json') &&
!result.headers.get('content-type')?.startsWith('application/graphql+json')
) {
throw new Error(
`Failed to fetch: server returned invalid response with error ${result.status}: ${result.statusText}`
Expand Down

0 comments on commit d7b30f0

Please sign in to comment.