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:
@@ -15,6 +15,7 @@ LABEL org.opencontainers.image.title="Jellomator" \
|
||||
org.opencontainers.image.source="${VCS_URL}" \
|
||||
org.opencontainers.image.revision="${VCS_REF}"
|
||||
COPY backend ./backend
|
||||
COPY public ./public
|
||||
COPY --from=frontend /app/frontend/dist ./frontend/dist
|
||||
RUN pip install --no-cache-dir -r backend/requirements.txt
|
||||
EXPOSE 6363
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="theme-color" content="#020617" />
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/static/jellomator.png" />
|
||||
<link rel="shortcut icon" href="/static/jellomator.png" />
|
||||
<link rel="apple-touch-icon" href="/static/jellomator.png" />
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/jellomator.png" />
|
||||
<link rel="shortcut icon" href="/jellomator.png" />
|
||||
<link rel="apple-touch-icon" href="/jellomator.png" />
|
||||
<title>Jellomator</title>
|
||||
<script>
|
||||
if (localStorage.theme === 'light') document.documentElement.classList.remove('dark');
|
||||
|
||||
Reference in New Issue
Block a user