-
Couldn't load subscription status.
- Fork 75
[Server] Make CORS headers configurable in StreamableHttpTransport #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Server] Make CORS headers configurable in StreamableHttpTransport #118
Conversation
|
Thanks for jumping on that @CodeWithKyrian 👍 @soyuka does that solve the issue for you? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comment
| private readonly ResponseFactoryInterface $responseFactory, | ||
| private readonly StreamFactoryInterface $streamFactory, | ||
| array $corsHeaders = [], | ||
| private readonly LoggerInterface $logger = new NullLogger(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason you don't set corsHeaders at the end to avoid breaking current implementations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, wanted to keep things consistent with how the logger is passed across the SDK ie it’s always the last argument, and I think that consistency makes things more predictable overall. Since we haven’t tagged a release yet, this kind of breaking change is still fair game (for now).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup agree, we'd need to tag soon and care more than tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs a rebase tho
e115158 to
78d1509
Compare
…ertel) This PR was merged into the main branch. Discussion ---------- [MCP Bundle] Fix transport arguments of McpController | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Docs? | no | Issues | | License | MIT Follows modelcontextprotocol/php-sdk#118 Commits ------- ee141ea Fix transport arguments of McpController
This PR introduces the ability to configure CORS headers in
StreamableHttpTransport, addressing the opinionated and inflexible header implementation that was previously hardcoded.Motivation and Context
The current CORS implementation was explicitly set with fixed headers, limiting flexibility for different deployment scenarios. As raised in #112, this approach hid security settings and provided no way to adapt them when using reverse proxies like nginx or when specific CORS policies are required.
What's Changed
corsHeadersparameter toStreamableHttpTransportconstructorBreaking Changes
Minor: The logger parameter has shifted one position in the constructor signature.
If you’re passing it positionally, you’ll now need to include the new corsHeaders array parameter before it. Named arguments or cases where logger is omitted remain unaffected.
This change aligns the parameter order with how logger is handled consistently across the SDK.