c2-core: fix CORS so the browser can call the REST API (#110) #120

Merged
logan merged 1 commits from fix/110-c2-core-cors into main 2026-09-07 19:06:25 -04:00
Owner

The Archive page's GET /calls/search failed its CORS preflight in prod. CORSMiddleware was already mounted but settings.cors_origins defaulted to ["*"] and the live VM .env carries no matching CORS_ORIGINS, so Starlette emitted no Access-Control-* headers.

  • config.py: default cors_origins -> ["https://drb.cusano.net"] (verified against infra: bare domain only, no app. vhost)
  • main.py: explicit methods + authorization/content-type headers, allow_credentials=False hard-off
  • new tests/test_cors.py (4 cases); test_cors_policy.py updated to the no-credentials invariant
  • .env.example documents CORS_ORIGINS

Sandboxed pytest 305 -> 309, green. VM action: ensure /opt/drb/drb-c2-core/.env has no stale explicit CORS_ORIGINS overriding the new default. Closes #110.

🤖 Generated with Claude Code

The Archive page's `GET /calls/search` failed its CORS preflight in prod. `CORSMiddleware` was already mounted but `settings.cors_origins` defaulted to `["*"]` and the live VM .env carries no matching `CORS_ORIGINS`, so Starlette emitted no `Access-Control-*` headers. - `config.py`: default `cors_origins` -> `["https://drb.cusano.net"]` (verified against infra: bare domain only, no `app.` vhost) - `main.py`: explicit methods + `authorization`/`content-type` headers, `allow_credentials=False` hard-off - new `tests/test_cors.py` (4 cases); `test_cors_policy.py` updated to the no-credentials invariant - `.env.example` documents `CORS_ORIGINS` Sandboxed pytest 305 -> 309, green. **VM action:** ensure `/opt/drb/drb-c2-core/.env` has no stale explicit `CORS_ORIGINS` overriding the new default. Closes #110. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
logan added 1 commit 2026-09-07 19:03:12 -04:00
The Archive page's GET /calls/search failed its CORS preflight (OPTIONS -> 405, no Access-Control-* headers). Allow the app origin(s) explicitly for the standard methods and the authorization/content-type headers.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01Tbknwttzou4s46PAykmtix
logan merged commit cea094d66b into main 2026-09-07 19:06:25 -04:00
logan deleted branch fix/110-c2-core-cors 2026-09-07 19:06:25 -04:00
Sign in to join this conversation.