When building medium-to-large Next.js applications, we often need to perform some preprocessing before requests enter the application, such as user authentication, internationalization settings, and redirects. Starting with version 12, Next.js supports Middleware, which runs on edge nodes and can intercept and process requests before they reach page components. This article will explain step by step…