Skip to content

fix: pass allowed methods to CORS middleware - #670

Merged
nieblara merged 5 commits into
launchdarkly:mainfrom
vissersg:vissersg/cors-method-support
Sep 16, 2026
Merged

nieblara merged 5 commits into
launchdarkly:mainfrom
vissersg:vissersg/cors-method-support

Conversation

@vissersg

@vissersg vissersg commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues
#669

Describe the solution you've provided

When setting up the CORS middleware each router now passes in a list of methods that it supports, and the middleware handler uses that list to set AllowedMethods. This replaces the hardcoded GET method to ensure all methods are properly handled.

Describe alternatives you've considered

Provide a clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context about the pull request here.


Note

Overview
Replaces the dev server’s single GET-only CORS middleware with CorsHeadersForMethods, so each SDK route subrouter advertises the HTTP methods it actually supports (e.g. GET + REPORT on /eval and /sdk/evalx, GET on goals).

Route registration now shares the same method list between mux routing and CORS AllowedMethods, fixing preflight failures when browsers request non-GET methods like REPORT. Adds cors_test.go to assert OPTIONS preflight allows configured methods and rejects others.

Reviewed by Cursor Bugbot for commit 0f8f39d. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Comment thread internal/dev_server/sdk/routes.go Outdated
@nieblara
nieblara merged commit 945917d into launchdarkly:main Sep 16, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants