I'm working on a Next.js 14 app while learning Next.js and to some extent React at the same time. I'm probably just doing something wrong.
I'm using Xano to register and login users. My goal is to use middleware to check the routes against the Xano authToken cookie, (right now on all routes for simplicity and later I will change it to just routes that need protection).
I understand that I need to have the middleware.ts at the root of the project, (I'm not using a SRC folder). So, I've placed it at the same level as my package.json. It looks like this right now:
import { NextResponse } from "next/server";
export default function middleware(req: any) {
console.log('run middleware');
}
I expected this to confirm it would run on every route, (using next/Link to navigate), and then add my auth logic. I do not see anything in the console. It's either not working, or I'm misunderstanding how this should work.
Can anyone shed some light on what I should expect and do here?
Not sure if I should just delete my post or admit how much of a dope I am. Guess I'll leave this for the next dummy lol. I was looking at the browser console, not terminal. It's working just fine.