Prevent redirect to login page if User is not authenticated

Hi,

i cant find a solution on my own … I have setup a fresh next js project and installed @auth0/nextjs-auth0 … i created a middleware because i want to do some redirects based on authentication.

When i enter my application on localhost:3000/ and am not authenticated i want the user to see a landingpage with Login Button, that navigates to /api/auth/login from auth0 sdk. And when i enter localhost:3000/ and am authenticated nothing should happen.

export default withMiddlewareAuthRequired({
  async middleware(req) {
    const res = NextResponse.next();
    const session = await getSession(req, res);
    const user = session?.user;
    console.log({ user });

    if (!user) {
      return NextResponse.redirect(new URL('/landingpage', req.url));
    }

    return res;
  },
});

This is my middleware and with this code auth0 always redirects directly to their login page.

Edit: Not even the console.log is fired. middleware.ts is on the same level as the app/ directory