Skip to content

chore(dev): allow any localhost port to call the local API (CORS) - #2698

Merged
eddy-geek merged 1 commit into
masterfrom
chore/cors-any-localhost-port
Nov 23, 2026
Merged

eddy-geek merged 1 commit into
masterfrom
chore/cors-any-localhost-port

Conversation

@eddy-geek

Copy link
Copy Markdown
Contributor

The local API (config/env.dev) allowed only http://localhost:6553 and http://localhost:8080 for 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 own common.ini.

Change

  • cors_allowed_origins in config/env.dev is now http://localhost:6553 http://localhost:[0-9]* http://127.0.0.1:[0-9]*.
  • Origins are already matched with fnmatch (web/cors.py). The port has to start with a digit, so no other host matches: http://localhost.evil.example is refused.
  • 6553 stays first, as the contract snapshots expect.
  • Production is unchanged: config/env.default keeps its explicit origins, and a bare * is still refused.
  • README updated.

Tests

  • New test_a_pattern_allows_the_ports_of_a_host: allows localhost:8095, refuses localhost.evil.example and evil.example.
  • test_cors_policy.py and contract/test_cors.py pass. ruff is clean.

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.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

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.

@eddy-geek
eddy-geek merged commit 384bbf0 into master Nov 23, 2026
7 checks passed
@eddy-geek
eddy-geek deleted the chore/cors-any-localhost-port branch November 23, 2026 19:09
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