Error: The edge runtime does not support Node.js 'crypto' module.

I dont know what i'm doing wrong during the setup of next auth

import type { NextAuthConfig } from "next-auth"
import Credentials from "next-auth/providers/credentials";
import { LoginSchema } from "@/schemas";
import { getUserByEmail } from "@/data/user";

import bcrypt from "bcryptjs";

export default {
    providers: [
        Credentials({
            async authorize(credentials) {
                if(!credentials) return null;

                const validatedFields = LoginSchema.safeParse(credentials);

                if(validatedFields.success) {
                    const {email, password} = validatedFields.data;

                    const user = await getUserByEmail(email);

                    if(!user || !user.password) return null;

                    const passwordsMatch = await bcrypt.compare(
                        password,
                        user.password,
                    );

                    if(passwordsMatch) return {
                        ...user,
                        id: String(user.id),
                      };
                }

                return null;
            }
        })
    ],
} satisfies NextAuthConfig


import NextAuth from "next-auth"
import { DrizzleAdapter } from "@auth/drizzle-adapter"
import { db } from "@/lib/db";
import authConfig from "@/auth.config"

export const { handlers, auth, signIn, signOut } = NextAuth({
  adapter: DrizzleAdapter(db),
  session: {strategy: "jwt"},
  ...authConfig,
})


```
Was this page helpful?