Handle CORS preflight for MCP proxy - #6669
Open
lorenzozanee wants to merge 1 commit into
Open
lorenzozanee wants to merge 1 commit into
lorenzozanee wants to merge 1 commit into
Conversation
lorenzozanee
requested review from
ChrisJBurns,
JAORMX,
amirejaz,
blkt,
jhrozek and
rdimitrov
as code owners
September 15, 2026 18:45
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6669 +/- ##
==========================================
+ Coverage 79.08% 79.09% +0.01%
==========================================
Files 785 785
Lines 78381 78390 +9
==========================================
+ Hits 61989 62005 +16
+ Misses 16387 16380 -7
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
Allowlisted browser requests to the MCP proxy could not complete CORS negotiation: preflight requests reached the MCP method handler and successful responses lacked CORS headers. This change handles allowed preflight requests in the existing exact Origin allowlist middleware and adds the corresponding headers to allowed responses.
Fixes #4297
Type of change
Test plan
task test)task test-e2e)task lint-fix)Focused unit tests for the origin middleware,
go test ./pkg/transport/...,go vet ./pkg/transport/..., andgit diff --checkpassed. The repository'staskandgolangci-lintcommands were unavailable in the local environment, so their checklist items remain unchecked.API Compatibility
v1beta1API, OR theapi-break-allowedlabel is applied and the migration guidance is described above.Does this introduce a user-facing change?
Yes. Browser clients from an explicitly allowed Origin receive a successful
/mcppreflight and the CORS headers needed for MCP requests. Disallowed Origins remain rejected, and an empty allowlist remains pass-through without enabling CORS.Special notes for reviewers
The existing exact Origin allowlist is the sole source of CORS permission: no wildcard or arbitrary Origin reflection is introduced. Suggested reviewers for the transport area are @JAORMX, @jhrozek, and @blkt.
Supersedes #6652 (原PR分支已删,按原提交重建)