mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[GH-ISSUE #263] Bug: External rewrite proxy causes ERR_CONTENT_DECODING_FAILED in browser #67
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#67
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @17hz on GitHub (Mar 5, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/263
Description
When using
rewritesinnext.config.tsto proxy requests to an external backend, the browser fails withERR_CONTENT_DECODING_FAILED(net error).Root Cause
Node.js
fetch()automatically decompresses response bodies (gzip, br, deflate), butproxyExternalRequest(inconfig-matchers.ts) and__proxyExternalRequest(inlined inapp-dev-server.ts) forward the upstreamcontent-encodingandcontent-lengthheaders as-is to the browser.The browser sees
content-encoding: gzipand attempts to decompress the body again, but it has already been decompressed by Node — resulting inERR_CONTENT_DECODING_FAILED.Reproduction
Any request to
/api/...that returns a gzip-compressed response from the backend will fail in the browser.Expected Behavior
The proxy should strip
content-encodingandcontent-lengthfrom the upstream response headers before forwarding to the browser, since Nodefetch()has already decompressed the body.Suggested Fix
In both
proxyExternalRequest(config-matchers.ts) and__proxyExternalRequest(app-dev-server.ts), filter outcontent-encodingandcontent-lengthwhen building response headers:Environment