options.providers is not iterable
Unanswered
Pacific sand lance posted this in #help-forum
Pacific sand lanceOP
I was trying to learn NextAuth from the documentations for my next app and i get hit with this error which i don't fully understand, can anyone help me?
code :
Error :
code :
// /lib/auth.js
import CredentialsProvider from "next-auth/providers/credentials";
export const authOptions = {
providers: [
CredentialsProvider({
name: "Credentials",
credentials: {
username: { label: "Username", type: "text", placeholder: "jsmith" },
password: { label: "Password", type: "password" }
},
async authorize(credentials, req) {
const user = { id: "1", name: "J Smith", email: "jsmith@example.com" }
if (user) {
return user
} else {
return null
}
}
})
]
}// /app/api/auth/[...nextauth]/route.js
import NextAuth from "next-auth/next";
import { authOptions } from "@/lib/auth";
export const handler = NextAuth({authOptions})
export { handler as GET, handler as POST}Error :
⨯ TypeError: options.providers is not iterable
at assertConfig (webpack-internal:///(rsc)/./node_modules/next-auth/core/lib/assert.js:43:36)
at AuthHandler (webpack-internal:///(rsc)/./node_modules/next-auth/core/index.js:90:54)
at async NextAuthRouteHandler (webpack-internal:///(rsc)/./node_modules/next-auth/next/index.js:50:30)
at async NextAuth._args$ (webpack-internal:///(rsc)/./node_modules/next-auth/next/index.js:85:24)
at async /home/lacri/Documents/code stuff/alharom/alharomapp/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:62361