Next.js · Middle · Question 21 of 75

What does proxy.ts (formerly middleware) do?

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.

Further reading

Problem with a question

Next.js · Middle · question 21

Test yourself

Take the Next.js · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz