Skip to content

Commit 5edbba6

Browse files
JihaoXinclaude
andcommitted
Fix /dashboard (no trailing slash) returning 404
Starlette's Mount at /dashboard matches /dashboard/... but also catches bare /dashboard, passing empty path to the sub-app which has no route for "". Add an explicit GET /dashboard route on the outer app (before the mount) that 301-redirects to /dashboard/. Browser follows the redirect transparently. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8d2ab23 commit 5edbba6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

website/dashboard/app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,16 @@ def create_app():
505505

506506
# ── Outer app (homepage + dashboard mount) ─────────────────────────
507507
outer = FastAPI(title="ARK Research Portal", lifespan=lifespan)
508+
509+
# Starlette's Mount matches /dashboard/ but NOT bare /dashboard (it
510+
# passes empty string to the sub-app which 404s). Register a redirect
511+
# BEFORE the mount so /dashboard → /dashboard/ works.
512+
from fastapi.responses import RedirectResponse as _Redir
513+
514+
@outer.get(DASHBOARD_PREFIX)
515+
async def _dashboard_redirect():
516+
return _Redir(DASHBOARD_PREFIX + "/", status_code=301)
517+
508518
outer.mount(DASHBOARD_PREFIX, dashboard)
509519

510520
# Serve the static homepage as catch-all at /. Must be mounted LAST

0 commit comments

Comments
 (0)