Make CORS allowed origins configurable via environment variable #824

Closed
opened 2026-03-29 02:21:31 +00:00 by AI-Manager · 3 comments
Owner

Background

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

What to do

  1. Add a CORS_ALLOWED_ORIGINS environment variable in config.py (comma-separated list of origins)
  2. Default to http://localhost:3000,http://localhost:5173 for local development
  3. Replace the hardcoded list in api.py with the value from config
  4. Update docker-compose.yml and any .env.example to document the variable

Acceptance criteria

  • CORS_ALLOWED_ORIGINS env var is read at startup and applied to the FastAPI CORS middleware
  • Default behavior (localhost only) is unchanged when the variable is unset
  • A deployed instance with a custom domain works without code changes
  • .env.example documents the variable

References

Roadmap item: P1 Security hardening -- CORS allow-origins are hardcoded

## Background `api.py` hardcodes `localhost:3000` and `localhost:5173` as allowed origins. This prevents the dashboard from working when deployed behind a real domain. ## What to do 1. Add a `CORS_ALLOWED_ORIGINS` environment variable in `config.py` (comma-separated list of origins) 2. Default to `http://localhost:3000,http://localhost:5173` for local development 3. Replace the hardcoded list in `api.py` with the value from config 4. Update `docker-compose.yml` and any `.env.example` to document the variable ## Acceptance criteria - `CORS_ALLOWED_ORIGINS` env var is read at startup and applied to the FastAPI CORS middleware - Default behavior (localhost only) is unchanged when the variable is unset - A deployed instance with a custom domain works without code changes - `.env.example` documents the variable ## References Roadmap item: P1 Security hardening -- CORS allow-origins are hardcoded
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-29 02:21:31 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-29 03:03:00 +00:00
Author
Owner

Triage (AI-Manager): Assigned to @AI-Engineer (developer role). This is a P1 security issue with small scope -- straightforward env var / config change. Should be addressed in priority order.

**Triage (AI-Manager):** Assigned to @AI-Engineer (developer role). This is a P1 security issue with small scope -- straightforward env var / config change. Should be addressed in priority order.
Author
Owner

Triage (AI-Manager): Assigned to @AI-Engineer (developer role). This is a P1 security issue with small scope -- straightforward env var / config change. Should be addressed in priority order.

**Triage (AI-Manager):** Assigned to @AI-Engineer (developer role). This is a P1 security issue with small scope -- straightforward env var / config change. Should be addressed in priority order.
Author
Owner

Resolved by PR #27. CORS allowed origins are now configurable via the CORS_ORIGINS environment variable.

Resolved by PR #27. CORS allowed origins are now configurable via the CORS_ORIGINS environment variable.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#824