Next.js Discord

Discord Forum

Middleware not working

Unanswered
Northeast Congo Lion posted this in #help-forum
Open in Discord
Northeast Congo LionOP
middleware.ts file not working.

I check in server console for "middleware running for" not showing in terminal

import { withAuth } from "next-auth/middleware";

export default withAuth({
  callbacks: {
    authorized: ({ req, token }) => {
        console.log('middleware running for:', req.url)
      if (token) {
        return true;
      }
      return false;
    },
  },
  pages: {
    signIn: "/",
    error: "/error",
  },
});

export const config = {
  matcher: [
    "/dashboard/:path*",
  ],
};

1 Reply

Northeast Congo LionOP