Middleware-based Route Protection
The middleware.ts file runs on the Edge before every matched request. Check the session token and redirect to /login if it's missing — no protected page HTML ever reaches an unauthenticated user.
The middleware.ts file runs on the Edge before every matched request. Check the session token and redirect to /login if it's missing — no protected page HTML ever reaches an unauthenticated user.