fix: serve static assets from the SPA dist before falling back to index.html
Browse filesThe fallback handler was returning index.html for every non-API path, which meant requests for the bundled logo and any other static file inside frontend/dist landed back as HTML and the browser refused to decode them as images. The handler now checks whether the requested path resolves to a real file under FRONTEND_DIST and serves it directly, keeping the index.html fallback only for client-side router paths.
- src/api/main.py +3 -0
src/api/main.py
CHANGED
|
@@ -117,6 +117,9 @@ def _mount_frontend() -> None:
|
|
| 117 |
from fastapi import HTTPException
|
| 118 |
|
| 119 |
raise HTTPException(status_code=404, detail="Not found")
|
|
|
|
|
|
|
|
|
|
| 120 |
index = FRONTEND_DIST / "index.html"
|
| 121 |
if index.exists():
|
| 122 |
return FileResponse(index)
|
|
|
|
| 117 |
from fastapi import HTTPException
|
| 118 |
|
| 119 |
raise HTTPException(status_code=404, detail="Not found")
|
| 120 |
+
static_file = FRONTEND_DIST / full_path
|
| 121 |
+
if full_path and static_file.is_file():
|
| 122 |
+
return FileResponse(static_file)
|
| 123 |
index = FRONTEND_DIST / "index.html"
|
| 124 |
if index.exists():
|
| 125 |
return FileResponse(index)
|