Skip to content

middlewares + Next

Course: Middlwares in next - chapter 2

Ref - https://nextjs.org/docs/app/building-your-application/routing/middleware

Middleware allows you to run code before a request is completed.

Then, based on the incoming request, you can modify the response by

  1. rewriting
  2. redirecting
  3. modifying the request or response headers
  4. or responding directly.
  • Authentication and Authorization: Ensure user identity and check session cookies before granting access to specific pages or API routes.
  • Logging and Analytics: Capture and analyze request data for insights before processing by the page or API.