fix(proxy): ignore incoming accept-encoding header#1423
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds ChangesIgnore accept-encoding in proxy
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
pi0x
left a comment
There was a problem hiding this comment.
Note: this review was performed by AI agents (Claude Code) on behalf of the maintainer, in two independent passes.
Pass 1 reviewed the diff for correctness, edge cases, and test coverage. Pass 2 (a fresh agent, adversarial by design) independently re-read the diff, checked for merge conflicts/CI status, and tried to find a reason to block approval before this review was posted. Both passes agree this change is correct, adequately tested, and safe to merge.
Caveat: this repo's real CI workflow (lint + build + vitest) requires maintainer approval to run on fork PRs and has not executed on this PR yet — only automated third-party checks (CodeRabbit, Socket Security) have run. Please trigger/approve the CI workflow before merging.
v1 strips the incoming
accept-encodingheader before proxying (#914). The v2ignoredHeadersset insrc/utils/internal/proxy.tsaddedacceptbut droppedaccept-encoding, sogetProxyRequestHeadersforwards the client'saccept-encodingto the target.proxy()removescontent-encodingfrom the upstream response, relying on the runtime's fetch having already decoded the body. Forwarding the client'saccept-encodinglets the target pick an encoding the runtime's fetch may not decode (the zstd-on-undici case from nitrojs/nitro#2880 that #914 addressed); the still-encoded body would then be passed on without acontent-encodingheader. Since h3 v2 runs across runtimes whose fetch clients support different encoding sets, this restores the v1 behavior by addingaccept-encodingback to the set so the runtime fetch negotiates and decodes the encoding itself.Added a regression test: proxying a request that sends
accept-encoding: zstd, br, gzipnow asserts the upstream does not receive it. Without the change the header is forwarded (web and node test targets); with it the header is dropped. Full suite passes.Ref: #914
Summary by CodeRabbit
accept-encodingheaders are no longer forwarded upstream.accept-encodingis stripped before reaching the upstream request.