Next.js · Middle · Question 21 of 75
What does proxy.ts (formerly middleware) do?
- ✓Correct answer: Runs before the request is handled: redirects, rewrites, headers
- 2Proxies all
fetches from server components through a shared cache - 3Swaps React components depending on the device
Explanation
Proxy intercepts requests at the network boundary: redirecting unauthenticated users, A/B tests, locales, headers. Its scope is set with matcher. Don't use it for heavy logic or as the only authorization check - permissions should also be checked close to the data.