Spaces:
Runtime error
Runtime error
fix: Add Vercel production URL to CORS allowed origins
Browse files- src/api/main.py +4 -1
src/api/main.py
CHANGED
|
@@ -48,11 +48,14 @@ app = FastAPI(
|
|
| 48 |
origins = os.getenv("ALLOWED_ORIGINS", "http://localhost:3000,http://localhost:3001").split(",")
|
| 49 |
if not origins or origins == [""]:
|
| 50 |
origins = ["*"]
|
| 51 |
-
# Always include common localhost ports
|
| 52 |
if "http://localhost:3001" not in origins:
|
| 53 |
origins.append("http://localhost:3001")
|
| 54 |
if "http://localhost:3000" not in origins:
|
| 55 |
origins.append("http://localhost:3000")
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
app.add_middleware(
|
| 58 |
CORSMiddleware,
|
|
|
|
| 48 |
origins = os.getenv("ALLOWED_ORIGINS", "http://localhost:3000,http://localhost:3001").split(",")
|
| 49 |
if not origins or origins == [""]:
|
| 50 |
origins = ["*"]
|
| 51 |
+
# Always include common localhost ports and production URLs
|
| 52 |
if "http://localhost:3001" not in origins:
|
| 53 |
origins.append("http://localhost:3001")
|
| 54 |
if "http://localhost:3000" not in origins:
|
| 55 |
origins.append("http://localhost:3000")
|
| 56 |
+
# Add Vercel production URL
|
| 57 |
+
if "https://road-damage-on5d.vercel.app" not in origins:
|
| 58 |
+
origins.append("https://road-damage-on5d.vercel.app")
|
| 59 |
|
| 60 |
app.add_middleware(
|
| 61 |
CORSMiddleware,
|