fix(backend): serve static assets from disk before SPA catch-all

fallback
This commit is contained in:
kiskaadee committed 2026-09-30 22:13:38 -05:00
1 parent a7567aa69b
commit 856da792e0
3 files changed
+10

No files matched your search

+2
View File
@@ -14,6 +14,8 @@ backend/data/
# Build output
frontend/dist/
backend/static/
*.tsbuildinfo
# Data (volume-mounted, contains SQLite DB)
data/
+5
View File
@@ -75,6 +75,11 @@ if os.path.isdir(ASSETS_DIR):
@app.get("/birthday")
@app.get("/birthday/{full_path:path}")
async def spa_catch_all(full_path: str = ""):
if full_path:
requested_file = os.path.join(STATIC_DIR, full_path)
if os.path.isfile(requested_file):
return FileResponse(requested_file)
index_file = os.path.join(STATIC_DIR, "index.html")
if os.path.isfile(index_file):
return FileResponse(index_file)
+3
View File
@@ -106,3 +106,6 @@ def test_spa_catch_all(client):
res_subpath = client.get("/birthday/admin")
assert res_subpath.status_code == 200
res_font = client.get("/birthday/fonts/display.woff2")
assert res_font.status_code == 200