Next.js Discord

Discord Forum

Firestore in runtime issue

Unanswered
Asian black bear posted this in #help-forum
Open in Discord
Asian black bearOP
Hi, so I am working with AuthJS/NextAuth and setting up my creditials provider but running into an issue where it doesn't seem to work because I am querying from my firestore database the user but firestore can't run on the edge. I don't know exactly how to handle this. Here is the current state of the code.
 File name: auth.config.ts
//imports for everything
export default {
  providers: [
    Credentials({
      async authorize(credentials) {
        const validatedFields = LoginSchema.safeParse(credentials);

        if (validatedFields.success) {
          const { email, password } = validatedFields.data;
          const user = await getUserByEmail(email);
          if (!user || !user.password) {
            //Note that the !user.password is to stop login from other providers
            return null;
          }
          const passwordMatch = await bcrypt.compare(password, user.password);

          if (passwordMatch) {
            return user;
          }

          return;
        }
      },
    }), 
// rest of the providers and code.

0 Replies