Next.js Discord

Discord Forum

TypeError: options.providers is not iterable

Unanswered
SkippTekk posted this in #help-forum
Open in Discord
Hi there, this is the error im getting from trying to get data from my database using Prism.

import NextAuth from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
import { PrismaClient } from "@prisma/client";
import bcrypt from 'bcryptjs'

const handler = NextAuth({
    Providers: [
        CredentialsProvider({
            id: 'credentials',
            name: 'Credentials',
            credentials: {
                username: { label: 'username', type: 'text', placeholder: 'Username' },
                password: { label: 'password', type: 'password', placeholder: 'Password' }
            },
            async authorize(credentials) {
                const prisma = new PrismaClient();

                try {
                    const user = await prisma.users.findMany({ username: credentials.username })
                    console.log(credentials.password, credentials.username)

                    if (user) {
                        const isPassword = bcrypt.compare(
                            credentials.password, user.password
                        );

                        if (isPassword) {
                            await prisma.$disconnect()
                            return user
                        } else {
                            await prisma.$disconnect()
                            throw new Error('Password is 404')
                        }
                    } else {
                        await prisma.$disconnect()
                        throw new Error('User not found.')
                    }
                } catch (error) {
                    await prisma.$disconnect()
                    throw new Error(err)
                }

            }
        })
    ],
    pages: {
        error: '/login'
    }
})
export { handler as GET, handler as POST };


Not exactly sure by what the error means.

0 Replies