A middleware in Next.js can be used to run code before a request is completed. Then, based on the incoming request, we can modify the response by rewriting, redirecting, modifying the request or response headers or responding directly.<br /><br />In this video I'm showing how I'm controlling access to a route using a middleware.