Features
Middleware

Middleware

Middleware is a function that has access to the request and response object. It can execute any code, make changes to the request and response objects, end the request-response cycle, and call the next middleware function in the stack.

You can access the middleware in src/middleware.ts.

Because we are using NextAuth for authentication, every route you will create will be protected by default. You can change this behavior in by modifying the config matcher in src/middleware.ts.

export const config = {
	matcher: ["/((?!api|_next/static|_next/image|.*\\..*|favicon.ico).*)"],
};

To disable authentication for a specific route, you can add it next to favicon.ico in the matcher array.

export const config = {
	matcher: [
		"/((?!api|_next/static|_next/image|.*\\..*|favicon.ico|/my-route).*)",
	],
};