From 27352c84e5ab0b7edd99dda8dcaeb0ab19208ef8 Mon Sep 17 00:00:00 2001 From: bruno Date: Tue, 21 Jul 2026 13:51:31 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20404=20pages=20=E2=86=92=20redirect=20to?= =?UTF-8?q?=20/workspaces?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- app/main.py | 10 +++++----- tests/test_app.py | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/main.py b/app/main.py index d6f528c..0742360 100644 --- a/app/main.py +++ b/app/main.py @@ -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) diff --git a/tests/test_app.py b/tests/test_app.py index 0a2e3a1..33a9a80 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1950,11 +1950,10 @@ def test_create_page_defaults_to_untitled(client): def test_styled_404_page(client): - """Unknown routes return a styled 404 HTML page.""" + """Unknown routes redirect to /workspaces.""" resp = client.get("/this-does-not-exist-xyz", follow_redirects=False) - assert resp.status_code == 404 - assert "404" in resp.text - assert "FlowDeck" in resp.text + assert resp.status_code == 302 + assert resp.headers.get("location") == "/workspaces" def test_api_404_returns_json(client):