From 51aef1c2fbb47f1a2942aa037f303c25800f143c Mon Sep 17 00:00:00 2001 From: dekun Date: Sun, 2 Aug 2026 12:47:52 +0800 Subject: [PATCH] Fix control SPA refresh 404 on /stats by serving index.html. Co-authored-by: Cursor --- control/backend/app/main.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/control/backend/app/main.py b/control/backend/app/main.py index 9c506fd..4d32f22 100644 --- a/control/backend/app/main.py +++ b/control/backend/app/main.py @@ -59,16 +59,15 @@ if (_DIST / "assets").is_dir(): @app.get("/") @app.get("/monitor") +@app.get("/stats") @app.get("/settings") @app.get("/login") -async def spa(full_path: str = ""): +async def spa(): index = _DIST / "index.html" if index.exists(): return FileResponse(index) - if Path(__file__).name: - return { - "ok": True, - "msg": "control frontend not built; cd control/frontend && npm ci && npm run build", - "health": "/health", - } - raise HTTPException(status_code=404, detail="frontend missing") + return { + "ok": True, + "msg": "control frontend not built; cd control/frontend && npm ci && npm run build", + "health": "/health", + }