This commit is contained in:
dvirlabs 2025-12-31 02:38:47 +02:00
parent 40f264a08a
commit af515c587d

View File

@ -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=["*"],