Cleanuop and CORS fixing

This commit is contained in:
James Pattinson
2025-10-13 19:30:19 +00:00
parent d37027ee5a
commit ecbc38cf8e
6 changed files with 359 additions and 6 deletions

View File

@@ -54,12 +54,15 @@ app = FastAPI(
)
# Add CORS middleware
# Get allowed origins from environment or use secure defaults
ALLOWED_ORIGINS = os.getenv('ALLOWED_ORIGINS', 'http://localhost:3000,http://127.0.0.1:3000').split(',')
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # In production, specify your frontend domain
allow_origins=ALLOWED_ORIGINS, # Specific origins only
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
allow_methods=["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"], # Specific methods
allow_headers=["Authorization", "Content-Type", "Accept", "Origin", "X-Requested-With"], # Specific headers
)
security = HTTPBearer()