From 78556bbfee2e1888c2e138e0a031bee655e92ad3 Mon Sep 17 00:00:00 2001 From: adam Date: Sat, 7 Mar 2026 03:23:45 +0000 Subject: [PATCH] Fix SPA serving conflicting with API routes --- main.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 99cb57e..f2f53fa 100644 --- a/main.py +++ b/main.py @@ -55,16 +55,8 @@ async def health(): return HealthCheck(status="ok", tools=_tool_status) -# Serve built frontend static files (must be after all /api routes) +# Serve built frontend static files — mounted last so /api routes take priority. STATIC_DIR = Path(__file__).parent / "static" if STATIC_DIR.exists(): - app.mount("/assets", StaticFiles(directory=STATIC_DIR / "assets"), name="assets") - - @app.get("/{full_path:path}") - async def serve_spa(full_path: str): - """Catch-all: serve index.html for SPA routing.""" - file_path = STATIC_DIR / full_path - if file_path.is_file(): - return FileResponse(file_path) - return FileResponse(STATIC_DIR / "index.html") + app.mount("/", StaticFiles(directory=STATIC_DIR, html=True), name="static")