Kataba's own 404 page, with a real 404 status for guests (#80) #81

Merged
miko merged 5 commits from feature/80-not-found into development 2026-11-04 19:22:59 +01:00
Owner

Closes #80

Summary

kataba's own 404 page replaces Next.js's: a big "404" whose zero is the kataba mark, hopping on its shadow (still with reduced motion), a short playful text and a link back to the start page. It has a tab title and German translations.

src/app/not-found.tsx
  <HoppingFourOFour>          # 4 · LogoMark (monochrome, ADR-0010) · 4
  <Suspense><NotFoundText>    # heading, text, "Back to the start page"

Missing content answered 200 everywhere: with Cache Components the prerendered shell goes out before a page's notFound(). Guests now get a real 404 from a proxy (ADR-0017):

proxy(request)
  if guest page load (GET, no rsc header, no session cookie)
     and hiddenFromGuest(path)        # missing or hidden from guests: same answer
    rewrite → /_kataba/not-found      # no route matches → not-found page, 404
  else
    let the page decide               # as before

hiddenFromGuest covers top-level page slugs, /c/…, /guides/… (reading, edit, new) and /admin/…. It reads straight from the database (only the columns visibility needs), because neither "use cache" nor auth() runs in the proxy. A top-level name is a page slug unless it is in APP_ROUTE_NAMES, which a test keeps exactly in step with src/app. If the check fails, the page decides.

Evidence

  • Before: curl /typo /login /c/x /guides/x /admin/settings → 200 200 200 200 200
    After (guest, GET and HEAD): → 404 404 404 404 404; /, /search, /icon.svg → 200; with a session cookie → 200 (unchanged)
  • New in e2e/notFound.spec.ts: an unknown address shows the kataba 404 page and leads home; a guest gets status 404 for a mistyped slug, /login, /guides, /c/…, /guides/…, /guides/new and /admin/settings. In access.spec and pages.spec, a guest on a hidden guide, a draft page or an internal page now also gets 404. In authoring.spec and pages.spec, a guest gets 200 for a published category, guide and page.
  • Lint and typecheck clean; vitest 374/374; Playwright 50/50.

Merge Danger

Door: two-way

Revert the commits and it's back to before. No data or schema changes.

Blast Radius: routing

The proxy runs on every page load. If hiddenFromGuest ever disagreed with a page's own check, a guest would see the 404 page for content they may read. The 200 assertions and the guest reads in the e2e suite would catch that. A database error in the check leaves the address to the page; it no longer turns into a 500. When a route's check changes, hiddenFromGuest has to change with it. Signed-in visitors still get status 200 on not-found. Guest page loads of content cost one or two extra DB reads.

🤖 Generated with Claude Code

Closes #80 ## Summary kataba's own 404 page replaces Next.js's: a big "404" whose zero is the kataba mark, hopping on its shadow (still with reduced motion), a short playful text and a link back to the start page. It has a tab title and German translations. ```text src/app/not-found.tsx <HoppingFourOFour> # 4 · LogoMark (monochrome, ADR-0010) · 4 <Suspense><NotFoundText> # heading, text, "Back to the start page" ``` Missing content answered **200** everywhere: with Cache Components the prerendered shell goes out before a page's `notFound()`. Guests now get a real **404** from a proxy (ADR-0017): ```text proxy(request) if guest page load (GET, no rsc header, no session cookie) and hiddenFromGuest(path) # missing or hidden from guests: same answer rewrite → /_kataba/not-found # no route matches → not-found page, 404 else let the page decide # as before ``` `hiddenFromGuest` covers top-level page slugs, `/c/…`, `/guides/…` (reading, edit, new) and `/admin/…`. It reads straight from the database (only the columns visibility needs), because neither `"use cache"` nor `auth()` runs in the proxy. A top-level name is a page slug unless it is in `APP_ROUTE_NAMES`, which a test keeps exactly in step with `src/app`. If the check fails, the page decides. ## Evidence - **Before:** `curl /typo /login /c/x /guides/x /admin/settings` → `200 200 200 200 200` **After (guest, GET and HEAD):** → `404 404 404 404 404`; `/`, `/search`, `/icon.svg` → `200`; with a session cookie → `200` (unchanged) - New in `e2e/notFound.spec.ts`: an unknown address shows the kataba 404 page and leads home; a guest gets status 404 for a mistyped slug, `/login`, `/guides`, `/c/…`, `/guides/…`, `/guides/new` and `/admin/settings`. In `access.spec` and `pages.spec`, a guest on a hidden guide, a draft page or an internal page now also gets 404. In `authoring.spec` and `pages.spec`, a guest gets **200** for a published category, guide and page. - Lint and typecheck clean; vitest 374/374; Playwright 50/50. ## Merge Danger **Door:** two-way Revert the commits and it's back to before. No data or schema changes. **Blast Radius:** routing The proxy runs on every page load. If `hiddenFromGuest` ever disagreed with a page's own check, a guest would see the 404 page for content they may read. The 200 assertions and the guest reads in the e2e suite would catch that. A database error in the check leaves the address to the page; it no longer turns into a 500. When a route's check changes, `hiddenFromGuest` has to change with it. Signed-in visitors still get status 200 on not-found. Guest page loads of content cost one or two extra DB reads. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Unknown addresses and every notFound() now render a kataba page instead
of Next.js's default: a large "404" whose zero is the kataba mark,
hopping on its shadow (still with reduced motion), a short playful text
and a link back to the start page, translated into German. The
titlebar stays. The e2e helper expectNotFound checks the new heading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up: the hopping mark follows the text colour as ADR-0010
asks, the component is named after its hop, and the page sets a
translated "Page not found" tab title.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With Cache Components the prerendered shell goes out with status 200
before a page can call notFound(), so every missing page, category,
guide and admin page answered 200. A proxy now checks guests' page
loads before rendering: when the address shows a guest nothing,
missing or hidden alike, it is rewritten to an unmatched address and
the not-found page answers 404. Signed-in visitors, client navigations
and anything the check cannot place are left to the page (ADR-0017).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A failed check (database error, malformed address) leaves the address
  to the page instead of answering 500.
- Categories are read as id, parent, slug and visibility only, uncached
  but light; the proxy no longer pulls in the cached loaders.
- Top-level names the app does not route (/login, /guides) answer 404:
  APP_ROUTE_NAMES, kept exactly in step with src/app by a test, now
  decides what is a page slug; RESERVED_PAGE_SLUGS builds on it.
- HEAD requests are checked like GET; Next's dev endpoints are skipped.
- e2e: a guest gets 200 for a published category, guide and page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
miko merged commit d31529559a into development 2026-11-04 19:22:59 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MassiveDynamic/kataba!81
No description provided.