Repository navigation
chore(dev): allow any localhost port to call the local API (CORS) - #2698
Merged
Merged
Conversation
A UI dev server on another port than 8080 (several worktrees, a second server pointed at the local API) was refused by the CORS policy of the local API. config/env.dev now allows any port of localhost and 127.0.0.1, as fnmatch patterns whose port starts with a digit, so that no other host matches. Production keeps its explicit origins.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
The local API (
config/env.dev) allowed onlyhttp://localhost:6553andhttp://localhost:8080for CORS. A c2c_ui dev server on any other port was refused: several worktrees on 8091–8095, or a second server pointed at the local API while another uses prod. Each developer had to edit their owncommon.ini.Change
cors_allowed_originsinconfig/env.devis nowhttp://localhost:6553 http://localhost:[0-9]* http://127.0.0.1:[0-9]*.fnmatch(web/cors.py). The port has to start with a digit, so no other host matches:http://localhost.evil.exampleis refused.6553stays first, as the contract snapshots expect.config/env.defaultkeeps its explicit origins, and a bare*is still refused.Tests
test_a_pattern_allows_the_ports_of_a_host: allowslocalhost:8095, refuseslocalhost.evil.exampleandevil.example.test_cors_policy.pyandcontract/test_cors.pypass. ruff is clean.