Add configurable CORS middleware#14
Merged
Merged
Conversation
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
Adds CORS middleware to the FastAPI application so browser-based clients can make cross-origin requests. The middleware is disabled by default (empty origins list) and activated only when
IMG_CORS_ORIGINSis set, ensuring zero impact on existing deployments.Changes
cors_origins,cors_allow_methods,cors_allow_headers(env vars:IMG_CORS_ORIGINS,IMG_CORS_ALLOW_METHODS,IMG_CORS_ALLOW_HEADERS)CORSMiddlewarewhencors_originsis non-empty[2.2.0]release entryConfiguration
IMG_CORS_ORIGINS[]["http://localhost:3000"]; empty = disabled)IMG_CORS_ALLOW_METHODS["GET","POST","PUT","DELETE","OPTIONS"]IMG_CORS_ALLOW_HEADERS["*"]Usage
Version bump
MINOR (2.1.0 → 2.2.0) — new backward-compatible feature, no breaking changes.
Checklist
ruff check— all checks passedruff format— no changes neededmypy— no issues foundpytest— 216/216 tests passed