From 856da792e07ebc15ce37a1802209f37aa4ef8bd1 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Wed, 30 Sep 2026 22:13:38 -0500 Subject: [PATCH] fix(backend): serve static assets from disk before SPA catch-all fallback --- .gitignore | 2 ++ backend/app/main.py | 5 +++++ backend/tests/test_config.py | 3 +++ 3 files changed, 10 insertions(+) diff --git a/.gitignore b/.gitignore index fe1b2a3..1d1ddc3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ backend/data/ # Build output frontend/dist/ +backend/static/ +*.tsbuildinfo # Data (volume-mounted, contains SQLite DB) data/ diff --git a/backend/app/main.py b/backend/app/main.py index f2d365a..f292fdb 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -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) diff --git a/backend/tests/test_config.py b/backend/tests/test_config.py index 21235f5..2b58673 100644 --- a/backend/tests/test_config.py +++ b/backend/tests/test_config.py @@ -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