i am trying to make an auth in nextjs. and in the root middleware.ts i have this:
import { auth } from "./auth";
export default auth((req) => {
const isLoggedIn = !!req.auth;
console.log("Is Logged In: ", isLoggedIn);
});
export const config = {
matcher: [
// Skip Next.js internals and all static files, unless found in search params
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
// Always run for API routes
'/(api|trpc)(.*)',
],
};
i have been following this https://authjs.dev/getting-started/installation?framework=next-js and using latest nextjs.
now the problem is when i just refresh the /auth/login route. i am expecting this:
console.log("Is Logged In: ", isLoggedIn);
to make log on the server terminal but its not, its just
✓ Ready in 3.2s
○ Compiling /auth/register ...
✓ Compiled /auth/register in 3.3s (735 modules)
✓ Compiled in 970ms (340 modules)
GET /auth/register 200 in 4384ms
○ Compiling /auth/login ...
✓ Compiled /auth/login in 760ms (733 modules)
GET /auth/login 200 in 885ms
GET /auth/register 200 in 32ms
do you have any idea?
i am new to nextjs, so this is a little challenge