feat: 404 pages → redirect to /workspaces
- 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:
+5
-5
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user