Recently, I delved into NextJs and NextAuth while working on a page accessible to admins only. I came across the intriguing concept of a "middleware.ts" file, which is supposed to run a function for each specified route. However, I encountered an issue where my minimalistic console log in the file doesn't seem to display anything in the browser's inspect tool or the terminal.
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
export function middleware(request: NextRequest) {
console.log("MIDDLEWARE EXECUTED FROM: ", request.url);
return NextResponse.next();
}
export const config = {
matcher: "/((?!api|_next/static|_next/image|favicon.ico).*)",
};
Additionally, the file is named middleware.ts and can be found in the root directory. I have been grappling with this issue for the past three days and would greatly appreciate any assistance.