sushilideaclan01 commited on
Commit
a54c80e
·
1 Parent(s): aec470c

Fix catch-all route to not interfere with API routes

Browse files
Files changed (1) hide show
  1. main.py +5 -3
main.py CHANGED
@@ -4,6 +4,7 @@ Handles video generation, image processing, and API integrations
4
  """
5
 
6
  from fastapi import FastAPI, HTTPException, Request, Response
 
7
  from fastapi.middleware.cors import CORSMiddleware
8
  from fastapi.responses import StreamingResponse, JSONResponse
9
  from fastapi.staticfiles import StaticFiles
@@ -139,11 +140,12 @@ if os.path.exists(frontend_dist_path):
139
  }
140
 
141
  # Serve frontend index.html for all non-API routes
 
142
  @app.get("/{full_path:path}")
143
- async def serve_frontend(full_path: str):
144
  """Serve frontend for all non-API routes"""
145
- # Don't serve frontend for API routes or docs
146
- if (full_path.startswith("api") or
147
  full_path.startswith("docs") or
148
  full_path.startswith("redoc") or
149
  full_path.startswith("openapi.json") or
 
4
  """
5
 
6
  from fastapi import FastAPI, HTTPException, Request, Response
7
+ from fastapi import Request as FastAPIRequest
8
  from fastapi.middleware.cors import CORSMiddleware
9
  from fastapi.responses import StreamingResponse, JSONResponse
10
  from fastapi.staticfiles import StaticFiles
 
140
  }
141
 
142
  # Serve frontend index.html for all non-API routes
143
+ # This must be last to not interfere with API routes
144
  @app.get("/{full_path:path}")
145
+ async def serve_frontend(full_path: str, request: FastAPIRequest):
146
  """Serve frontend for all non-API routes"""
147
+ # Don't serve frontend for API routes or docs - let FastAPI handle these
148
+ if (full_path.startswith("api/") or
149
  full_path.startswith("docs") or
150
  full_path.startswith("redoc") or
151
  full_path.startswith("openapi.json") or