fix(backend): serve static assets from disk before SPA catch-all
fallback
This commit is contained in:
1 parent
a7567aa69b
commit
856da792e0
3 files changed
+10
No files matched your search
@@ -14,6 +14,8 @@ backend/data/
|
|||||||
|
|
||||||
# Build output
|
# Build output
|
||||||
frontend/dist/
|
frontend/dist/
|
||||||
|
backend/static/
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
# Data (volume-mounted, contains SQLite DB)
|
# Data (volume-mounted, contains SQLite DB)
|
||||||
data/
|
data/
|
||||||
|
|||||||
@@ -75,6 +75,11 @@ if os.path.isdir(ASSETS_DIR):
|
|||||||
@app.get("/birthday")
|
@app.get("/birthday")
|
||||||
@app.get("/birthday/{full_path:path}")
|
@app.get("/birthday/{full_path:path}")
|
||||||
async def spa_catch_all(full_path: str = ""):
|
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")
|
index_file = os.path.join(STATIC_DIR, "index.html")
|
||||||
if os.path.isfile(index_file):
|
if os.path.isfile(index_file):
|
||||||
return FileResponse(index_file)
|
return FileResponse(index_file)
|
||||||
|
|||||||
@@ -106,3 +106,6 @@ def test_spa_catch_all(client):
|
|||||||
|
|
||||||
res_subpath = client.get("/birthday/admin")
|
res_subpath = client.get("/birthday/admin")
|
||||||
assert res_subpath.status_code == 200
|
assert res_subpath.status_code == 200
|
||||||
|
|
||||||
|
res_font = client.get("/birthday/fonts/display.woff2")
|
||||||
|
assert res_font.status_code == 200
|
||||||
Reference in new issue
Block a user