fix(auth): use first X-Forwarded-Proto/Host token in publicOrigin#180
fix(auth): use first X-Forwarded-Proto/Host token in publicOrigin#180jony376 wants to merge 2 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
📝 WalkthroughWalkthroughThe PR adds a helper function to extract the first value from comma-separated forwarded headers and applies it when deriving the protocol and host in the ChangesForwarded header parsing fix
🎯 2 (Simple) | ⏱️ ~8 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 unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/lib/origin.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/origin.ts (1)
6-6: 💤 Low valueOptional: Remove redundant optional chaining.
The optional chaining
?.aftersplit(',')[0]is technically unnecessary becausesplit(',')always returns an array with at least one element, so[0]will never beundefined. However, the defensive style is harmless and may improve readability for future maintainers.♻️ Simplified version (optional)
- const first = value.split(',')[0]?.trim(); + const first = value.split(',')[0].trim();🤖 Prompt for 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. In `@src/lib/origin.ts` at line 6, The expression using redundant optional chaining on the split result should be simplified: in the assignment to the variable first (const first = value.split(',')[0]?.trim();), remove the unnecessary ?. after [0] since split(',') always returns at least one element, so change it to call trim() directly on the [0] result to avoid the needless optional check while preserving behavior.
🤖 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.
Nitpick comments:
In `@src/lib/origin.ts`:
- Line 6: The expression using redundant optional chaining on the split result
should be simplified: in the assignment to the variable first (const first =
value.split(',')[0]?.trim();), remove the unnecessary ?. after [0] since
split(',') always returns at least one element, so change it to call trim()
directly on the [0] result to avoid the needless optional check while preserving
behavior.
Summary
Use the first comma-separated
X-Forwarded-Protoand host token inpublicOriginso OAuth redirect URIs stay valid behind reverse proxies.Related Issues
Closes #178
Type of Change
Testing
Checklist
Summary by CodeRabbit