Make CORS allowed origins configurable via environment variable #1497

Closed
opened 2026-03-31 00:22:35 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 Security hardening

api.py hardcodes localhost:3000 and localhost:5173 as the only permitted CORS origins. This breaks the dashboard when deployed behind any real domain.

What to do

  1. In api.py, read a new env var CORS_ALLOWED_ORIGINS (comma-separated list of origins, e.g. https://sparc.example.com,http://localhost:3000).
  2. Fall back to the current hardcoded list only when the env var is absent and ENVIRONMENT=development.
  3. In non-development mode, if CORS_ALLOWED_ORIGINS is unset, log a warning (do not refuse to start).
  4. Update docker-compose.yml and any .env.example to document the new variable.

Acceptance criteria

  • CORS origins are read from CORS_ALLOWED_ORIGINS env var when set
  • Comma-separated multiple origins are all applied correctly
  • Fallback to localhost origins works in development
  • .env.example documents the variable
## Context Roadmap item: P1 Security hardening `api.py` hardcodes `localhost:3000` and `localhost:5173` as the only permitted CORS origins. This breaks the dashboard when deployed behind any real domain. ## What to do 1. In `api.py`, read a new env var `CORS_ALLOWED_ORIGINS` (comma-separated list of origins, e.g. `https://sparc.example.com,http://localhost:3000`). 2. Fall back to the current hardcoded list only when the env var is absent and `ENVIRONMENT=development`. 3. In non-development mode, if `CORS_ALLOWED_ORIGINS` is unset, log a warning (do not refuse to start). 4. Update `docker-compose.yml` and any `.env.example` to document the new variable. ## Acceptance criteria - [ ] CORS origins are read from `CORS_ALLOWED_ORIGINS` env var when set - [ ] Comma-separated multiple origins are all applied correctly - [ ] Fallback to localhost origins works in development - [ ] `.env.example` documents the variable
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-31 00:22:35 +00:00
Author
Owner

[Repo Manager] This issue is already resolved. SPARC/config.py reads CORS_ORIGINS from the environment (comma-separated), and api.py passes config.cors_origins to the CORSMiddleware. docker-compose.yml also exposes the variable. Closing as complete.

[Repo Manager] This issue is already resolved. `SPARC/config.py` reads `CORS_ORIGINS` from the environment (comma-separated), and `api.py` passes `config.cors_origins` to the CORSMiddleware. `docker-compose.yml` also exposes the variable. Closing as complete.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1497