diff --git a/app/main.py b/app/main.py index 89dcdd9..fa5d8ee 100644 --- a/app/main.py +++ b/app/main.py @@ -74,10 +74,14 @@ if os.path.exists(FRONTEND_DIR) and os.path.exists(ASSETS_DIR): async def serve_frontend(): return FileResponse(f"{FRONTEND_DIR}/index.html") - @app.get("/{path:path}") + # SPA fallback - MUST be last and NOT capture /api/* + @app.get("/{path:path}", include_in_schema=False) async def serve_spa(path: str): - if path.startswith("api/"): - return None # Let API routes handle + # Explicitly skip API routes + if path.startswith("api"): + from fastapi import HTTPException + raise HTTPException(status_code=404, detail="Not Found") + file_path = f"{FRONTEND_DIR}/{path}" if os.path.exists(file_path) and os.path.isfile(file_path): return FileResponse(file_path)