From 5fe1103cb4c51333f828a7d3425f46245b8b0f78 Mon Sep 17 00:00:00 2001 From: AhmadHammad21 Date: Sun, 7 Jun 2026 02:54:00 +0300 Subject: [PATCH] fix(api): serve root-level static files from the Vite build The SPA catch-all returned index.html for every non-/assets path, so root-level public files (favicon.svg, Emblem.svg, brand-mark.svg) came back as HTML and rendered as broken images. Serve real files from the dist root before the index.html fallback. --- apps/backend/src/api/app.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/backend/src/api/app.py b/apps/backend/src/api/app.py index ab25180..eb82e12 100644 --- a/apps/backend/src/api/app.py +++ b/apps/backend/src/api/app.py @@ -6,7 +6,7 @@ import litellm from fastapi import FastAPI -from fastapi.responses import HTMLResponse +from fastapi.responses import FileResponse, HTMLResponse from fastapi.staticfiles import StaticFiles from loguru import logger @@ -224,5 +224,10 @@ async def index(): @app.get("/{full_path:path}", response_class=HTMLResponse, include_in_schema=False) async def spa_fallback(full_path: str): - """Serve index.html for all client-side routes so React Router works on refresh.""" + """Serve root-level static files from the Vite build (favicon, logos, etc.), + falling back to index.html so React Router works on refresh.""" + if full_path and _DIST.is_dir(): + candidate = (_DIST / full_path).resolve() + if candidate.is_file() and candidate.is_relative_to(_DIST.resolve()): + return FileResponse(candidate) return _serve_index()