79312322

Date: 2024-12-27 16:34:52
Score: 2.5
Natty:
Report link

You can customize the authorized callback for a conditional check. On my side, I want to use an environment variable to skip logins if in development. I found this post after getting the same error you got.

See https://next-auth.js.org/configuration/nextjs#callbacks for more info.

In your case, you can do something like:

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

export default withAuth({
  callbacks: {
    authorized: ({
      token
    }) => !!token && process.env.NEXT_PUBLIC_AUTH_USERS === "true"
  },
}, );

export const config = {
  matcher: ["/folder/(.*)"]
}

Token will be set if user is logged in, otherwise will be null.

Reasons:
  • Whitelisted phrase (-1): In your case
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): getting the same error
  • Low reputation (1):
Posted by: bchang02