Fix icon routing and prevent SPA fallback on asset paths
All checks were successful
docker / build-and-push (push) Successful in 1m4s

This commit is contained in:
Space-Banane
2026-05-20 21:38:41 +02:00
parent 5d6be52e32
commit bd9d1234fb
3 changed files with 10 additions and 3 deletions

View File

@@ -298,11 +298,15 @@ if STATIC_DIR.exists():
app.mount("/assets", StaticFiles(directory=STATIC_DIR / "assets"), name="assets")
if PUBLIC_DIR.exists():
app.mount("/static", StaticFiles(directory=PUBLIC_DIR), name="public")
elif STATIC_DIR.exists():
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="public-dist")
@app.get("/jellomator.png")
def root_icon():
icon = PUBLIC_DIR / "jellomator.png"
if not icon.exists():
icon = STATIC_DIR / "jellomator.png"
if not icon.exists():
raise HTTPException(404, "Not found")
return FileResponse(icon)
@@ -312,6 +316,8 @@ def root_icon():
def spa(path: str):
if path.startswith("api/"):
raise HTTPException(404)
if "." in path:
raise HTTPException(404)
index = STATIC_DIR / "index.html"
if index.exists():
return FileResponse(index)