File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 3838import logging
3939logging .basicConfig (level = logging .INFO )
4040from 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 ()]
4144app = 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
4346app .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 = ["*" ],
You can’t perform that action at this time.
0 commit comments