404/redirect handling for unknown routes and subdomains #26

Open
opened 2026-04-19 07:23:34 +00:00 by forgejo-lila · 0 comments
Owner

Context

Unknown routes on the frontend show a blank page or raw error. Unknown subdomains show Caddy's default error page.

What to do

  1. Add a catch-all 404 page on the frontend.
  2. Handle unknown subdomains in Caddy.

Files to change

  • apps/web/src/routes/__root.tsx — TanStack Router supports a notFoundComponent. Add a styled 404 page.
  • Caddyfile (on VPS at ~/lila-app/) — add a catch-all block for unrecognized subdomains.
  • apps/api/src/app.ts — optionally add a catch-all route that returns JSON 404 instead of Express's default Cannot GET /path.

Acceptance criteria

  • lilastudy.com/nonexistent shows a styled 404 page with link back to home
  • random.lilastudy.com either redirects to lilastudy.com or shows a 404
  • api.lilastudy.com/nonexistent returns { "error": "Not Found" } with status 404
  • The 404 page matches existing styling (Tailwind + shadcn/ui)

Notes

TanStack Router docs on not found: https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors
The Caddyfile currently only defines blocks for lilastudy.com, api.lilastudy.com, and git.lilastudy.com. Wildcard DNS means any subdomain resolves to the VPS.

## Context Unknown routes on the frontend show a blank page or raw error. Unknown subdomains show Caddy's default error page. ## What to do 1. Add a catch-all 404 page on the frontend. 2. Handle unknown subdomains in Caddy. ## Files to change - `apps/web/src/routes/__root.tsx` — TanStack Router supports a `notFoundComponent`. Add a styled 404 page. - `Caddyfile` (on VPS at `~/lila-app/`) — add a catch-all block for unrecognized subdomains. - `apps/api/src/app.ts` — optionally add a catch-all route that returns JSON 404 instead of Express's default `Cannot GET /path`. ## Acceptance criteria - `lilastudy.com/nonexistent` shows a styled 404 page with link back to home - `random.lilastudy.com` either redirects to `lilastudy.com` or shows a 404 - `api.lilastudy.com/nonexistent` returns `{ "error": "Not Found" }` with status 404 - The 404 page matches existing styling (Tailwind + shadcn/ui) ## Notes TanStack Router docs on not found: https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors The Caddyfile currently only defines blocks for `lilastudy.com`, `api.lilastudy.com`, and `git.lilastudy.com`. Wildcard DNS means any subdomain resolves to the VPS.
forgejo-lila added the
ux
label 2026-04-19 07:23:34 +00:00
Sign in to join this conversation.
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: forgejo-lila/lila#26
No description provided.