mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-22 06:28:11 +02:00
fix(web): servir le favicon en production
Le fallback SPA renvoyait index.html pour /favicon.svg : l'icône n'apparaissait jamais. Les fichiers statiques racine existants sont maintenant servis tels quels, le reste retombe sur index.html. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
a85341da32
commit
7d1fa8913d
1 file changed
+14
-3
+14
-3
@@ -106,6 +106,17 @@ if os.path.isdir(_STATIC_DIR):
|
|||||||
|
|
||||||
@app.get("/{full_path:path}")
|
@app.get("/{full_path:path}")
|
||||||
async def spa_fallback(full_path: str):
|
async def spa_fallback(full_path: str):
|
||||||
"""Renvoie index.html pour toutes les routes (SPA React)."""
|
"""Fichier statique racine s'il existe (favicon…), sinon index.html.
|
||||||
index = os.path.join(_STATIC_DIR, "index.html")
|
|
||||||
return FileResponse(index)
|
Sans ce test, /favicon.svg recevait index.html : aucun favicon ne
|
||||||
|
s'affichait en production.
|
||||||
|
"""
|
||||||
|
static_root = os.path.abspath(_STATIC_DIR)
|
||||||
|
candidate = os.path.abspath(os.path.join(static_root, full_path))
|
||||||
|
if (
|
||||||
|
full_path
|
||||||
|
and candidate.startswith(static_root + os.sep)
|
||||||
|
and os.path.isfile(candidate)
|
||||||
|
):
|
||||||
|
return FileResponse(candidate)
|
||||||
|
return FileResponse(os.path.join(static_root, "index.html"))
|
||||||
Reference in new issue
Block a user