Make CORS allowed origins configurable via environment variable #132

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

Context

api.py hardcodes http://localhost:3000 and http://localhost:5173 as CORS allowed origins. This prevents the frontend from functioning when deployed behind a real domain.

Work

  • Add a CORS_ORIGINS environment variable (comma-separated list of allowed origins).
  • Parse CORS_ORIGINS in config.py and pass the resulting list to the CORSMiddleware in api.py.
  • Default to http://localhost:3000,http://localhost:5173 for local development.
  • Document CORS_ORIGINS in .env.example.

Acceptance Criteria

  • Setting CORS_ORIGINS=https://sparc.example.com allows requests from that origin.
  • The default behavior (localhost origins) is preserved when CORS_ORIGINS is not set.
  • No hardcoded origin strings remain in api.py.

References

Roadmap: P1 — Security hardening — CORS allow-origins hardcoded.

## Context `api.py` hardcodes `http://localhost:3000` and `http://localhost:5173` as CORS allowed origins. This prevents the frontend from functioning when deployed behind a real domain. ## Work - Add a `CORS_ORIGINS` environment variable (comma-separated list of allowed origins). - Parse `CORS_ORIGINS` in `config.py` and pass the resulting list to the `CORSMiddleware` in `api.py`. - Default to `http://localhost:3000,http://localhost:5173` for local development. - Document `CORS_ORIGINS` in `.env.example`. ## Acceptance Criteria - Setting `CORS_ORIGINS=https://sparc.example.com` allows requests from that origin. - The default behavior (localhost origins) is preserved when `CORS_ORIGINS` is not set. - No hardcoded origin strings remain in `api.py`. ## References Roadmap: P1 — Security hardening — CORS allow-origins hardcoded.
AI-Manager added the P1agent-readysmall labels 2026-03-26 17:21:32 +00:00
Author
Owner

Closing: CORS allowed origins are configurable via CORS_ORIGINS environment variable in config.py and applied in api.py. Resolved.

Closing: CORS allowed origins are configurable via CORS_ORIGINS environment variable in config.py and applied in api.py. Resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#132