Uh oh!
There was an error while loading. Please reload this page.
fix(proxy): strip hop-by-hop request headers (RFC 7230) - #804
Conversation
Per RFC 7230 §6.1, a proxy must not forward connection-specific hop-by-hop headers upstream. The handler already filters them on the response side via SKIP_RESPONSE_HEADERS; mirror that with a SKIP_REQUEST_HEADERS set covering connection, keep-alive, proxy-authenticate, proxy-authorization, te, trailer, transfer-encoding, upgrade. Also strip any header listed by name in the incoming Connection header value. Forwarding these can corrupt the upstream exchange (mis-framed bodies from a stale transfer-encoding, broken keep-alive negotiation) and has been observed to break Sentry proxying and native webview signals. Closes#791
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughThis PR adds RFC 7230 hop-by-hop request header filtering to the proxy handler. It introduces a Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/unit/proxy-handler-hop-by-hop.test.ts`:
- Around line 52-64: The test overrides globalThis.fetch (see the realFetch
assignment and the async replacement function) but never restores it, which can
leak into other tests; add a teardown that restores globalThis.fetch to
realFetch in an afterAll/afterEach block (matching the test lifecycle used) so
that the original fetch is reinstated after the tests complete, and ensure any
other similar overrides around lines 80-83 are also restored the same way.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 233d3a8e-6fa6-4fc1-81d6-048a4318a042
📒 Files selected for processing (2)
packages/script/src/runtime/server/proxy-handler.tstest/unit/proxy-handler-hop-by-hop.test.ts
Uh oh!
There was an error while loading. Please reload this page.
🔗 Linked issue
Resolves#791
❓ Type of change
📚 Description
The script proxy handler forwarded incoming request headers verbatim, including hop-by-hop headers that RFC 7230 §6.1 says must not be forwarded by intermediaries (
connection,keep-alive,proxy-authenticate,proxy-authorization,te,trailer,transfer-encoding,upgrade), nor any headers named in theConnectionheader value. Mirrors the existingSKIP_RESPONSE_HEADERSfilter on the response side. New unit test boots the actual proxy handler and asserts both static and Connection-named headers are stripped.