修复复盘保存 405:复盘改走成绩更新接口,并修正 API 404 回退。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+9
-1
@@ -71,9 +71,17 @@ if dist_dir is not None:
|
||||
if assets_dir.is_dir():
|
||||
app.mount("/assets", StaticFiles(directory=assets_dir), name="assets")
|
||||
|
||||
@app.api_route(
|
||||
"/api/{rest:path}",
|
||||
methods=["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"],
|
||||
include_in_schema=False,
|
||||
)
|
||||
async def api_not_found(rest: str):
|
||||
raise HTTPException(status_code=404, detail="Not Found")
|
||||
|
||||
@app.get("/{full_path:path}", include_in_schema=False)
|
||||
async def serve_spa(full_path: str):
|
||||
if full_path.startswith("api") or full_path.startswith("api/"):
|
||||
if full_path.startswith("api/") or full_path == "api":
|
||||
raise HTTPException(status_code=404, detail="Not Found")
|
||||
if full_path in ("", "index.html"):
|
||||
return FileResponse(dist_dir / "index.html")
|
||||
|
||||
Reference in New Issue
Block a user