Make CORS allowed origins configurable via environment variable #735

Closed
opened 2026-03-28 17:21:57 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap reference: P1 - Security hardening

api.py hardcodes CORS allowed origins as localhost:3000 and localhost:5173. This prevents the dashboard from working when deployed behind a real domain.

What to do

  1. Add a CORS_ALLOWED_ORIGINS environment variable to config.py (comma-separated list of allowed origins)
  2. Update api.py to read allowed origins from config instead of hardcoded values
  3. Default to the current localhost values for backward compatibility in development
  4. Update docker-compose.yml and any .env.example to document the variable

Acceptance criteria

  • CORS_ALLOWED_ORIGINS env var is read from config and passed to the CORS middleware
  • Defaults to http://localhost:3000,http://localhost:5173 when unset
  • No hardcoded origins remain in api.py
  • Variable is documented in .env.example or README
## Context Roadmap reference: P1 - Security hardening `api.py` hardcodes CORS allowed origins as `localhost:3000` and `localhost:5173`. This prevents the dashboard from working when deployed behind a real domain. ## What to do 1. Add a `CORS_ALLOWED_ORIGINS` environment variable to `config.py` (comma-separated list of allowed origins) 2. Update `api.py` to read allowed origins from config instead of hardcoded values 3. Default to the current localhost values for backward compatibility in development 4. Update `docker-compose.yml` and any `.env.example` to document the variable ## Acceptance criteria - [ ] `CORS_ALLOWED_ORIGINS` env var is read from config and passed to the CORS middleware - [ ] Defaults to `http://localhost:3000,http://localhost:5173` when unset - [ ] No hardcoded origins remain in `api.py` - [ ] Variable is documented in `.env.example` or README
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-28 17:21:57 +00:00
Author
Owner

Resolved. config.py reads CORS_ORIGINS env var (comma-separated), defaults to localhost dev origins. api.py passes config.cors_origins to CORS middleware. No hardcoded origins remain. Documented in .env.example.

**Resolved.** `config.py` reads `CORS_ORIGINS` env var (comma-separated), defaults to localhost dev origins. `api.py` passes `config.cors_origins` to CORS middleware. No hardcoded origins remain. Documented in `.env.example`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#735