Repository navigation
[WEB-10189] fix: derive CORS origins when none are configured - #10318
Conversation
When CORS_ALLOWED_ORIGINS is not set, the allowed origins are now derived from the instance's own base URLs. If none of those is configured either, all origins are still allowed, but without credentials.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 18 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Linked to Plane Work Item(s) This comment was auto-generated by Plane |
sriramveeraghanta
left a comment
There was a problem hiding this comment.
LGTM. The only setups that change are ones with neither CORS_ALLOWED_ORIGINS nor base URLs, and those already failed CSRF on writes. Non-blocking: a base URL with an explicit default port (https://x:443) won't match the browser origin. The session origin check has the same quirk.
When CORS_ALLOWED_ORIGINS is not set, the allowed origins are now derived from the instance's own base URLs. If none of those is configured either, all origins are still allowed, but without credentials.
…ane#10318) When CORS_ALLOWED_ORIGINS is not set, the allowed origins are now derived from the instance's own base URLs. If none of those is configured either, all origins are still allowed, but without credentials. (cherry picked from commit cb9071f)
Description
When
CORS_ALLOWED_ORIGINSwas unset or empty, the settings fell back toCORS_ALLOW_ALL_ORIGINS = TruewhileCORS_ALLOW_CREDENTIALSstayed on. The shipped env templates set the variable, so this affects hand-rolled deployments.A small helper,
_cors_settings, now decides the three settings:WEB_URL,APP_BASE_URL,ADMIN_BASE_URL,SPACE_BASE_URL,LIVE_BASE_URL), the same set the session origin check already trusts.CSRF_TRUSTED_ORIGINSis unchanged.Behavior change: a deployment with
CORS_ALLOWED_ORIGINSunset and a frontend on an origin that is not one of its configured base URLs loses credentialed CORS until it setsCORS_ALLOWED_ORIGINSor the matching base URL. This needs a release note.Type of Change
Screenshots and Media (if applicable)
Test Scenarios
plane/tests/unit/settings/test_cors_origins.py: explicit list wins; empty list plus base URLs gives those origins; nothing configured gives allow-all without credentials. 4 passed.CORS_ALLOWED_ORIGINSempty andWEB_URLset, and confirm the web origin gets credentialed CORS headers while another origin gets none.References
Created with Claude Code