diff --git a/backend/main.py b/backend/main.py index e30919f..279ef07 100644 --- a/backend/main.py +++ b/backend/main.py @@ -20,10 +20,18 @@ models.Base.metadata.create_all(bind=engine) app = FastAPI(title="Wedding Guest List API") +# Get allowed origins from environment +FRONTEND_URL = os.getenv("FRONTEND_URL", "http://localhost:5173") +allowed_origins = [FRONTEND_URL] + +# Add localhost for development if not already there +if "localhost" not in FRONTEND_URL: + allowed_origins.append("http://localhost:5173") + # Configure CORS app.add_middleware( CORSMiddleware, - allow_origins=["http://localhost:5173"], # Vite default port + allow_origins=allowed_origins, allow_credentials=True, allow_methods=["*"], allow_headers=["*"],