Fix icon routing and prevent SPA fallback on asset paths
All checks were successful
docker / build-and-push (push) Successful in 1m4s
All checks were successful
docker / build-and-push (push) Successful in 1m4s
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user