feat: 404 pages → redirect to /workspaces
FlowDeck CI / test (push) Failing after 4s
FlowDeck CI / docker (push) Has been skipped

- main.py: @app.exception_handler(404) → RedirectResponse(/workspaces)
- dashboard.py: page_detail 404 → RedirectResponse(/workspaces)
- tests: test_styled_404_page → 302 redirect
- API paths (containing /api) still get JSON 404, not redirect
- 143 tests passent
This commit is contained in:
2026-07-21 13:51:31 -04:00
parent bf329a4ba0
commit 27352c84e5
2 changed files with 8 additions and 9 deletions
+5 -5
View File
@@ -152,10 +152,10 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;backgrou
@app.exception_handler(404)
async def not_found_handler(request: Request, exc):
"""Styled 404 page matching the FlowDeck dark theme."""
from fastapi.responses import HTMLResponse
# API routes should get JSON, not HTML
if request.url.path.startswith("/api/") or request.url.path.startswith("/board/api/"):
"""Redirect 404 HTML pages to /workspaces. API routes still get JSON."""
# Preserve JSON 404 for all API-like paths (including /db/xxx/api)
if "/api" in request.url.path:
from fastapi.responses import JSONResponse
return JSONResponse({"detail": "Not found"}, status_code=404)
return HTMLResponse(NOT_FOUND_HTML, status_code=404)
from fastapi.responses import RedirectResponse
return RedirectResponse("/workspaces", status_code=302)