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.source="${VCS_URL}" \
|
||||||
org.opencontainers.image.revision="${VCS_REF}"
|
org.opencontainers.image.revision="${VCS_REF}"
|
||||||
COPY backend ./backend
|
COPY backend ./backend
|
||||||
|
COPY public ./public
|
||||||
COPY --from=frontend /app/frontend/dist ./frontend/dist
|
COPY --from=frontend /app/frontend/dist ./frontend/dist
|
||||||
RUN pip install --no-cache-dir -r backend/requirements.txt
|
RUN pip install --no-cache-dir -r backend/requirements.txt
|
||||||
EXPOSE 6363
|
EXPOSE 6363
|
||||||
|
|||||||
@@ -298,11 +298,15 @@ if STATIC_DIR.exists():
|
|||||||
app.mount("/assets", StaticFiles(directory=STATIC_DIR / "assets"), name="assets")
|
app.mount("/assets", StaticFiles(directory=STATIC_DIR / "assets"), name="assets")
|
||||||
if PUBLIC_DIR.exists():
|
if PUBLIC_DIR.exists():
|
||||||
app.mount("/static", StaticFiles(directory=PUBLIC_DIR), name="public")
|
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")
|
@app.get("/jellomator.png")
|
||||||
def root_icon():
|
def root_icon():
|
||||||
icon = PUBLIC_DIR / "jellomator.png"
|
icon = PUBLIC_DIR / "jellomator.png"
|
||||||
|
if not icon.exists():
|
||||||
|
icon = STATIC_DIR / "jellomator.png"
|
||||||
if not icon.exists():
|
if not icon.exists():
|
||||||
raise HTTPException(404, "Not found")
|
raise HTTPException(404, "Not found")
|
||||||
return FileResponse(icon)
|
return FileResponse(icon)
|
||||||
@@ -312,6 +316,8 @@ def root_icon():
|
|||||||
def spa(path: str):
|
def spa(path: str):
|
||||||
if path.startswith("api/"):
|
if path.startswith("api/"):
|
||||||
raise HTTPException(404)
|
raise HTTPException(404)
|
||||||
|
if "." in path:
|
||||||
|
raise HTTPException(404)
|
||||||
index = STATIC_DIR / "index.html"
|
index = STATIC_DIR / "index.html"
|
||||||
if index.exists():
|
if index.exists():
|
||||||
return FileResponse(index)
|
return FileResponse(index)
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta name="theme-color" content="#020617" />
|
<meta name="theme-color" content="#020617" />
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="/static/jellomator.png" />
|
<link rel="icon" type="image/png" sizes="32x32" href="/jellomator.png" />
|
||||||
<link rel="shortcut icon" href="/static/jellomator.png" />
|
<link rel="shortcut icon" href="/jellomator.png" />
|
||||||
<link rel="apple-touch-icon" href="/static/jellomator.png" />
|
<link rel="apple-touch-icon" href="/jellomator.png" />
|
||||||
<title>Jellomator</title>
|
<title>Jellomator</title>
|
||||||
<script>
|
<script>
|
||||||
if (localStorage.theme === 'light') document.documentElement.classList.remove('dark');
|
if (localStorage.theme === 'light') document.documentElement.classList.remove('dark');
|
||||||
|
|||||||
Reference in New Issue
Block a user