fix: handle relative Location URLs in redirect rewriting (#20)#104
fix: handle relative Location URLs in redirect rewriting (#20)#104
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughsetRedirectHostRewrite now resolves Location response headers against the proxy target by using Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Linked issue
Closes #20
Description
When a proxied server responds with a relative URL in the
Locationheader (e.g.,Location: /api/books/1for 201 Created), the proxy throws:This happens because
new URL(proxyRes.headers.location)on line 38 doesn't provide a base URL. Per RFC 9110, theLocationheader is allowed to contain a relative URI-reference.Fix
Pass
targetas the base URL to theURLconstructor:This resolves relative paths against the proxy target, which is the correct behavior for a reverse proxy.
Summary by CodeRabbit
Bug Fixes
Tests