Repository navigation
[Server] Fix CORS preflight behind authorization - #576
Merged
chr-hertel merged 1 commit intoOct 13, 2026
Merged
Conversation
chr-hertel
requested review from
CodeWithKyrian,
Nyholm and
soyuka
as code owners
October 10, 2026 01:56
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation is consistent with transport behavior and adequately covered by unit tests.
0 open findings
What changed in this PR
Fixes browser CORS preflight requests when MCP authorization and modern request headers are enabled.
Changes:
- Allows unauthenticated
OPTIONSrequests through authorization middleware. - Adds default MCP headers and prefix-based header matching to CORS handling.
- Adds tests and documentation for the updated behavior.
| File | Description |
|---|---|
src/Server/Transport/Http/Middleware/AuthorizationMiddleware.php |
Bypasses token validation for OPTIONS. |
src/Server/Transport/Http/Middleware/CorsMiddleware.php |
Supports MCP headers and header-prefix patterns. |
tests/Unit/Server/Transport/Http/Middleware/AuthorizationMiddlewareTest.php |
Tests unauthenticated preflight handling. |
tests/Unit/Server/Transport/Http/Middleware/CorsMiddlewareTest.php |
Tests default MCP headers and prefix matching. |
docs/run/authorization.md |
Documents middleware ordering and preflight behavior. |
CHANGELOG.md |
Records both CORS fixes. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
soyuka
approved these changes
Oct 13, 2026
…the MCP request headers
chr-hertel
force-pushed
the
fix-cors-preflight-auth
branch
from
October 13, 2026 21:24
a0334c8 to
b4a1d17
Compare
This was referenced Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Browser clients could not reach a server protected by
AuthorizationMiddleware:Authorizationheader, so it got a401and the browser blocked the request.AuthorizationMiddlewarenow letsOPTIONSthrough; the transport answers it without dispatching.CorsMiddlewaredid not allowMcp-Method,Mcp-NameandMcp-Param-*, which every2026-07-28request sends. An$allowedHeadersentry ending in*now matches requested headers by prefix.Follow-up to #566.
🤖 Generated with Claude Code