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
- rewriting
- redirecting
- modifying the request or response headers
- or responding directly.
Use cases
Section titled “Use cases”- 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.