Skip to content

fix: CORS default was allow-all while docs claimed a localhost allowlist - #128

Merged
Sirajmx merged 1 commit into
mainfrom
fix/cors-default
Sep 17, 2026
Merged

Sirajmx merged 1 commit into
mainfrom
fix/cors-default

Conversation

@atc964

@atc964 atc964 commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

cors_allowed_origins in src/ad_buyer/config/settings.py defaulted to "*" (allow all origins), while every docs page describing this setting (docs/guides/configuration.md, docs/guides/deployment-ops-guide.md, docs/ai-assistant/developer-setup.md) states the default is a localhost allowlist. This PR restores the code to match the documented, safe default.

Behavior change

Deployments that were relying on the implicit "*" default now get http://localhost:3000,http://localhost:8080 instead. Any deployment that needs browser clients from other origins to reach the API must now set CORS_ALLOWED_ORIGINS explicitly (env var, unchanged mechanism). The env override still works exactly as before; only the default changes.

Regression history

  • 2026-03-08 (ce043fe): safe default introduced, setting cors_allowed_origins to http://localhost:3000,http://localhost:8080 and replacing an unauthenticated wildcard CORS policy.
  • 2026-04-28 (59ddb9b, PR Fix MCP and CORS #83): default silently reverted to "*" as part of an MCP/CORS change. A same day follow up (10627e3, PR Restore SSE legacy + update tests + docs after PR #83 #85) updated tests/unit/test_random_seed_and_cors.py::test_settings_default_cors_origins to assert the wildcard instead of catching the regression, so CI stayed green while the default drifted from the documented behavior.
  • This PR restores cors_allowed_origins to http://localhost:3000,http://localhost:8080 and updates the test, and its now stale "wildcard is correct" comments, to assert and describe the restored default.

Test plan

  • ruff check src/ tests/ and ruff format --check src/ tests/ clean
  • Full tests/unit suite green: 3500 passed, 1 skipped
  • tests/unit/test_random_seed_and_cors.py (7 tests) passes, now asserting the localhost default
  • Confirmed CORS_ALLOWED_ORIGINS env override still works (unchanged code path, covered by test_settings_custom_cors_origins)
  • Docs already state the localhost default and required no changes

The CORS allowed origins default was changed to allow all origins
("*") in commit 59ddb9b on 2026-04-28, while the docs still describe
a localhost allowlist. Restore the safe default that commit ce043fe
introduced on 2026-03-08: http://localhost:3000,http://localhost:8080.

The CORS_ALLOWED_ORIGINS env var still overrides the default for any
deployment that needs a different origin list.

Update the test that had been changed to assert the wildcard default
so it now asserts the restored localhost allowlist.
@atc964
atc964 requested a review from Sirajmx September 14, 2026 19:36
@Sirajmx
Sirajmx merged commit 435da0f into main Sep 17, 2026
5 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.

2 participants