From 67d738baf3b8eaf8f4be1b1592f44ba11a03f100 Mon Sep 17 00:00:00 2001 From: Zac Gaetano Date: Sun, 5 Apr 2026 11:06:44 -0400 Subject: [PATCH] fix: mount SPA at root, fix WS route priority --- backend/main.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/backend/main.py b/backend/main.py index 16f3eb4..77188d0 100644 --- a/backend/main.py +++ b/backend/main.py @@ -989,9 +989,6 @@ async def remove_mcp_server(name: str): STATIC_DIR = Path("/app/static") if not STATIC_DIR.exists(): STATIC_DIR = Path("/app/frontend/dist") -if STATIC_DIR.exists(): - app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static") - app.mount("/assets", StaticFiles(directory=str(STATIC_DIR / "assets")), name="assets") if (STATIC_DIR / "assets").exists() else None @app.get("/") @@ -1002,12 +999,7 @@ async def serve_index(): return {"message": "Claude Persistent Agent API v3.0", "docs": "/docs"} -@app.get("/{full_path:path}") -async def serve_spa(full_path: str): - """Serve React SPA for all non-API routes.""" - if full_path.startswith("api/"): - raise HTTPException(404) - index = STATIC_DIR / "index.html" - if index.exists(): - return FileResponse(str(index)) - raise HTTPException(404) +# Mount static assets AFTER all API/WS routes are registered +# This ensures /api/* and WebSocket routes take priority +if STATIC_DIR.exists(): + app.mount("/", StaticFiles(directory=str(STATIC_DIR), html=True), name="spa")