fix(cors): reject preflight immediately if any requested header is disallowed#88
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
|
@visionEye0 Are you able to assign a review from the top right corner? otherwise it's alright |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
😂😂 Not the coderabbit one, asking for myself |
|
Tip For best results, initiate chat on the files or code changes.
|
I have fixed the issue where the CORS preflight would incorrectly return a successful 200/204 response when a mix of allowed and disallowed headers were requested.
What was changed:
I've updated src/http/handlers/cors/cors-handler.ts to strictly validate Access-Control-Request-Headers. The handler now ensures that every single header in the requested list is present in the allowedHeaders. If any requested header is missing from the allowed list, the preflight request is immediately rejected.
I've also updated the tests in src/http/handlers/cors/cors-handler.spec.ts to add a test case verifying this exact scenario
related issue - #76
Summary by CodeRabbit
Bug Fixes
Tests
Closes #76