admin管理员组

文章数量:1309947

I'm getting a server error with next-auth. I believe I used [...nextauth].js correctly but it's saying my () after my providers is incorrect.

here is the file my error is happening

⨯ TypeError: next_auth_providers_credentials__WEBPACK_IMPORTED_MODULE_1__ is not a function at CredentialsProvider (src\auth.js:9:4)

export const { handlers, signIn, signOut, auth } = NextAuth({
  providers: [
    CredentialsProvider({
      credentials: {
        username: { label: "Username", type: "text" },
        password: { label: "Password", type: "password" },
      },
      authorize: async (credentials) => {
        const { username, password } = await loginSchema.parseAsync(
          credentials
        );
        const user = await getUserFromDb(username);

        if (!user) throw new Error("Nom d'utilisateur introuvable.");

        const isValidPassword = await bcryptpare(password, user.password);
        if (!isValidPassword) {
          throw new Error("Identifiants incorrects.");
        }
        return user;
      },
    }),
  ],
  session: {
    strategy: "jwt",
    maxAge: 7 * 24 * 3600,
  },
  callbacks: {
    async session({ session, token }) {
      return { ...session, ...token };
    },
    async jwt({ token, user }) {
      return { ...token, ...user };
    },
  },
  basePath: "/api/auth",
  secret: process.env.NEXTAUTH_SECRET,
});

本文标签: next authnextauthproviderscredentialsWEBPACKIMPORTEDMODULE1 is not a functionStack Overflow