Spaces:
Sleeping
Sleeping
github-actions[bot] commited on
Commit ·
d8756b9
1
Parent(s): 6f8f1e2
Sync from GitHub main @ d974ca792dc2e7dde4ceceedeb28d8588052dd7d
Browse files- app/main.py +5 -3
app/main.py
CHANGED
|
@@ -153,9 +153,11 @@ async def legacy_nl2sql_redirect(request: Request):
|
|
| 153 |
"/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]
|
| 154 |
)
|
| 155 |
async def legacy_catch_all(request: Request, path: str):
|
| 156 |
-
|
| 157 |
-
if path.startswith("api/v1"):
|
| 158 |
-
|
|
|
|
|
|
|
| 159 |
return RedirectResponse(url=f"/api/v1/{path}", status_code=307)
|
| 160 |
|
| 161 |
|
|
|
|
| 153 |
"/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]
|
| 154 |
)
|
| 155 |
async def legacy_catch_all(request: Request, path: str):
|
| 156 |
+
# If it's already versioned, don't redirect (prevents infinite 307 loop)
|
| 157 |
+
if request.url.path.startswith("/api/v1/") or request.url.path == "/api/v1":
|
| 158 |
+
raise HTTPException(status_code=404, detail="Not Found")
|
| 159 |
+
|
| 160 |
+
# Redirect only legacy root-level endpoints
|
| 161 |
return RedirectResponse(url=f"/api/v1/{path}", status_code=307)
|
| 162 |
|
| 163 |
|