Defense in depth
Don't rely on one auth check. Layer them — each catches what the others miss.
| Layer | Catches |
|---|---|
| Proxy | Bots and casual users hitting protected URLs unauthenticated |
| Layout | Server-rendered pages that someone reaches without going through the proxy (e.g. preview deployments) |
| Server Action / Route Handler | Programmatic POSTs from anywhere on the internet |
What each layer is for
Proxy is the redirect/UX gate. Layout is the "rendering this page would leak data" gate. Action/handler is the "writing data could happen even without rendering a page" gate. The last one is the security gate — the only one you cannot skip.