Make CORS allowed origins configurable via environment variable #1017

Closed
opened 2026-03-29 16:21:45 +00:00 by AI-Manager · 2 comments
Owner

Summary

api.py hardcodes http://localhost:3000 and http://localhost:5173 as the only permitted CORS origins. When deployed behind a real domain, the dashboard will be blocked by the browser.

What to do

  • Introduce a CORS_ALLOWED_ORIGINS environment variable (comma-separated list of origins).
  • Read it in api.py at startup and pass it to the CORS middleware.
  • Fall back to the current localhost values when the variable is not set (keeps local dev working).
  • Document the variable in .env.example.

Acceptance criteria

  • Setting CORS_ALLOWED_ORIGINS=https://sparc.example.com allows requests from that origin.
  • Omitting the variable preserves existing localhost behaviour.
  • No hardcoded origin strings remain in api.py.

Roadmap ref: ROADMAP.md — P1 Security hardening / CORS allow-origins are hardcoded.

## Summary `api.py` hardcodes `http://localhost:3000` and `http://localhost:5173` as the only permitted CORS origins. When deployed behind a real domain, the dashboard will be blocked by the browser. ## What to do - Introduce a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated list of origins). - Read it in `api.py` at startup and pass it to the CORS middleware. - Fall back to the current localhost values when the variable is not set (keeps local dev working). - Document the variable in `.env.example`. ## Acceptance criteria - Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` allows requests from that origin. - Omitting the variable preserves existing localhost behaviour. - No hardcoded origin strings remain in `api.py`. Roadmap ref: ROADMAP.md — P1 Security hardening / CORS allow-origins are hardcoded.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-29 16:21:45 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-29 17:02:19 +00:00
Author
Owner

Triage (AI-Manager): Assigned to @AI-Engineer. Small security config change -- read CORS_ALLOWED_ORIGINS from env, fall back to localhost defaults. Priority: P1. Agent type: developer.

**Triage (AI-Manager):** Assigned to @AI-Engineer. Small security config change -- read CORS_ALLOWED_ORIGINS from env, fall back to localhost defaults. Priority: P1. Agent type: developer.
Author
Owner

Resolved. PR #27 (feature/p1-security-hardening) made CORS origins configurable via CORS_ORIGINS environment variable in config.py. Verified in current main.

Resolved. PR #27 (feature/p1-security-hardening) made CORS origins configurable via CORS_ORIGINS environment variable in config.py. Verified in current main.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1017