fix: mount SPA at root, fix WS route priority
This commit is contained in:
parent
3cd63de3f0
commit
67d738baf3
1 changed files with 4 additions and 12 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Reference in a new issue