Security: Make CORS allowed origins configurable via environment variable #468

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

Context

Roadmap item: P1 - Security hardening

Problem

api.py hardcodes localhost:3000 and localhost:5173 as allowed CORS origins. When deployed behind a real domain the dashboard will be blocked by CORS policy.

Task

  • Read allowed CORS origins from an environment variable (e.g., CORS_ALLOWED_ORIGINS, comma-separated).
  • Fall back to localhost:3000,localhost:5173 only when the variable is unset (for local development).
  • Update config.py to expose the new setting.
  • Update .env.example with the new variable and documentation.

Acceptance Criteria

  • CORS_ALLOWED_ORIGINS env var controls the allowed origins list.
  • Default still works for local development.
  • Config is read at startup, not hardcoded in middleware.
  • .env.example documents the variable.
## Context Roadmap item: P1 - Security hardening ## Problem `api.py` hardcodes `localhost:3000` and `localhost:5173` as allowed CORS origins. When deployed behind a real domain the dashboard will be blocked by CORS policy. ## Task - Read allowed CORS origins from an environment variable (e.g., `CORS_ALLOWED_ORIGINS`, comma-separated). - Fall back to `localhost:3000,localhost:5173` only when the variable is unset (for local development). - Update `config.py` to expose the new setting. - Update `.env.example` with the new variable and documentation. ## Acceptance Criteria - [ ] `CORS_ALLOWED_ORIGINS` env var controls the allowed origins list. - [ ] Default still works for local development. - [ ] Config is read at startup, not hardcoded in middleware. - [ ] `.env.example` documents the variable.
AI-Manager added the P1agent-readysmall labels 2026-03-27 22:21:31 +00:00
Author
Owner

Already implemented. CORS_ORIGINS is configurable via environment variable in SPARC/config.py (lines 63-70). The docker-compose.yml passes CORS_ORIGINS: ${CORS_ORIGINS:-} to the API container. Closing as completed.

Already implemented. `CORS_ORIGINS` is configurable via environment variable in `SPARC/config.py` (lines 63-70). The `docker-compose.yml` passes `CORS_ORIGINS: ${CORS_ORIGINS:-}` to the API container. Closing as completed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#468