Repository navigation
feat(http): add CORSConfig for the cross-origin policy of an API - #366
Merged
Merged
Conversation
CORSConfig turns the origins, headers and flags services take in their configuration into rs/cors options and a middleware. Unlike rs/cors an empty config allows nothing, and localhost is an explicit AllowLocalhost opt-in. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SS4MAwAn85D1gkEzLtjYaZ
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
http.CORSConfig(allowed origins, allow-localhost, methods, headers, exposed headers, credentials, private network, max age) withOptions(logger, debug)andMiddleware(logger, debug).rs/cors, which allows every origin when given none.*is explicit, and localhost is anAllowLocalhostopt-in.Content-TypeandAuthorizationheaders, 24h max age. Methods are left tors/cors. Credentials and private network are opt-in.connect-control, connect and eventbroker each carry their own copy of this policy; this lets them share it (dioad/connect#559).
Test plan
go test -race ./http/make lintshows no new findings (http/operations.goQF1002 is already on master)🤖 Generated with Claude Code
https://claude.ai/code/session_01SS4MAwAn85D1gkEzLtjYaZ