Skip to content

feat: Add core application configuration, CORS middleware, and origin restriction with corresponding tests.#2

Merged
kemalcalak merged 3 commits into
mainfrom
CORS
Mar 20, 2026
Merged

feat: Add core application configuration, CORS middleware, and origin restriction with corresponding tests.#2
kemalcalak merged 3 commits into
mainfrom
CORS

Conversation

@kemalcalak
Copy link
Copy Markdown
Owner

@kemalcalak kemalcalak commented Mar 20, 2026

Note

Medium Risk
Adds a global HTTP middleware that blocks requests from non-allowlisted Origin headers (returning 404), which can break legitimate clients/proxies if origin/host handling is misconfigured. Behavior changes apply to all endpoints and methods, so regression risk is moderate despite being a contained change.

Overview
Introduces a strict Origin allowlist middleware that returns a generic 404 (RESOURCE_NOT_FOUND) for requests whose Origin is not in settings.all_cors_origins, while explicitly allowing same-origin requests.

Updates Settings.all_cors_origins to only append FRONTEND_HOST when set, and adds async tests covering allowed origins, blocked cross-origin requests, and same-origin POST/PUT behavior.

Written by Cursor Bugbot for commit cb3c208. This will update automatically on new commits. Configure here.

@kemalcalak
Copy link
Copy Markdown
Owner Author

@cursor review

Comment thread app/main.py
@kemalcalak
Copy link
Copy Markdown
Owner Author

@cursor review

Comment thread app/tests/test_origin_restriction.py Outdated
@kemalcalak
Copy link
Copy Markdown
Owner Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@kemalcalak kemalcalak merged commit c22b4d7 into main Mar 20, 2026
2 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.

1 participant