Skip to content

Commit aad76fa

Browse files
committed
chore: configure CORS origins from env vars
1 parent 3b4c110 commit aad76fa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

api/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@
3838
import logging
3939
logging.basicConfig(level=logging.INFO)
4040
from fastapi.middleware.cors import CORSMiddleware
41+
# Read CORS origins from environment (CORS_ORIGINS or ALLOWED_ORIGINS)
42+
_cors_env = os.getenv("CORS_ORIGINS") or os.getenv("ALLOWED_ORIGINS", "")
43+
ALLOWED_ORIGINS = [u.strip() for u in _cors_env.split(",") if u.strip()]
4144
app = FastAPI(title="Prompt Bootstrapper API")
42-
# Enable CORS so the static front-end can call API from a different origin
45+
# Enable CORS so specified front-ends can call the API
4346
app.add_middleware(
4447
CORSMiddleware,
45-
allow_origins=["*"], # adjust to specific origins in production
48+
allow_origins=ALLOWED_ORIGINS or ["*"], # use env list or fallback to all
4649
allow_credentials=True,
4750
allow_methods=["*"],
4851
allow_headers=["*"],

0 commit comments

Comments
 (0)