fix: pass allowed methods to CORS middleware - #670
Open
vissersg wants to merge 4 commits into
Open
Conversation
nieblara
approved these changes
Mar 25, 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.

Requirements
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 hardcodedGETmethod 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
Low Risk
Scoped to local dev-server SDK CORS configuration; no auth or production API changes.
Overview
Fixes browser CORS preflights on dev-server SDK routes that use REPORT (and other non-GET verbs) by aligning CORS
AllowedMethodswith each subrouter’s real methods instead of a shared middleware that only allowed GET.The shared
CorsHeadersvariable is replaced withCorsHeadersForMethods, which builds gorilla CORS from a per-route method list./evaland/sdk/evalx/{envId}passGETandREPORT;/sdk/goals/{envId}passesGET. RouteMethods(...)definitions reuse the same slices (plusOPTIONS).Adds
TestCorsHeadersto assert OPTIONS preflight success for allowed methods and rejection (noAccess-Control-Allow-Origin) for disallowed ones.Reviewed by Cursor Bugbot for commit a073dd3. Bugbot is set up for automated code reviews on this repo. Configure here.