Skip to content

fix(client): add Accept: application/json header to all generated fetch requests#290

Merged
benjamineckstein merged 2 commits into
mainfrom
fix/289-accept-json-header
Jun 10, 2026
Merged

fix(client): add Accept: application/json header to all generated fetch requests#290
benjamineckstein merged 2 commits into
mainfrom
fix/289-accept-json-header

Conversation

@benjamineckstein

Copy link
Copy Markdown
Contributor

Summary

Closes #289

The generated fetch client was omitting Accept: application/json from all requests. In a browser, the default Accept: text/html,... header was sent, causing server frameworks that perform content-negotiation (Laravel, Rails, Django REST Framework, etc.) to return HTML or redirect responses instead of JSON error bodies.

  • Adds 'Accept': 'application/json' as the first default header in both _request and _requestForm generated helpers
  • Placed before ...headers spread so users can override it via the headers config field
  • Consistent with the existing Content-Type: application/json behaviour for request bodies

Test plan

  • All existing tests pass (snapshots updated to include the new header)
  • Manually verify: any server doing content-negotiation now receives Accept: application/json and returns JSON error bodies

…ch requests

Servers that content-negotiate (Laravel, Rails, Django REST Framework) return
HTML or redirects instead of JSON error bodies when no Accept header is sent.
The new emitAcceptHeader helper inserts 'Accept': 'application/json' as the
first entry in both _request and _requestForm headers blocks, before ...headers
so callers can still override the header via the config field.
@github-actions

Copy link
Copy Markdown
Contributor

Fallow audit report

Found 2 findings.

Details
Severity Rule Location Description
minor fallow/unused-dev-dependency examples/package.json:15 Package '@tanstack/react-query' is in devDependencies but never imported; imported in other workspaces: packages/integration
minor fallow/unused-dev-dependency examples/package.json:17 Package 'react' is in devDependencies but never imported; imported in other workspaces: packages/integration

Generated by fallow.

@github-actions

Copy link
Copy Markdown
Contributor

Fallow audit report

0 inline findings selected for GitHub review.

@benjamineckstein benjamineckstein merged commit 6e8b895 into main Jun 10, 2026
7 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated client omits Accept: application/json, breaking error content-negotiation on server frameworks

1 participant