Next.js · Middle · Question 44 of 75
Where is the right place to check authorization in the App Router?
- ✓Correct answer: Close to the data: in the Data Access Layer, Server Actions and Route Handlers
- 2Only in
proxy.ts- after it, all routes are considered protected - 3Only in a client component, by hiding buttons from guests
Explanation
Proxy is fine for optimistic checks and redirects but shouldn't be the only protection: Server Actions are called directly, and layouts don't re-render on navigation. Check the session and permissions reliably where data is read and changed. Hiding buttons on the client isn't security.