NextAuth problems
Unanswered
Polish Tatra Sheepdog posted this in #help-forum
Polish Tatra SheepdogOP
Hello All,
I am trying to implement authentication into my app but keep experiencing stupid errors that I've never encountered. I am trying to use the GitHub provider, however, whenever I attempt to sign in I am immediately redirected to /undefined and the following error is spammed in my console.
Thanks for your attention to this matter 🙂
I am trying to implement authentication into my app but keep experiencing stupid errors that I've never encountered. I am trying to use the GitHub provider, however, whenever I attempt to sign in I am immediately redirected to /undefined and the following error is spammed in my console.
Thanks for your attention to this matter 🙂
3 Replies
Polish Tatra SheepdogOP
app/api/[...nextauth]/route.tsimport NextAuth from "next-auth"
import GitHub from "next-auth/providers/github"
import { PrismaAdapter } from "@auth/prisma-adapter"
import {database} from "@/app/lib/database"
const db = database()
export const {
signOut,
signIn,
handlers,
auth,
} = NextAuth({
adapter: PrismaAdapter(db),
providers: [GitHub({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET,
})],
useSecureCookies: false,
callbacks: {
async session({token, session}) {
// @ts-ignore
session.user = await db.user.findFirst({
where: {
// @ts-ignore
email: session.user.email,
},
});
return session
},
}
})removed
{ strategy: "jwt" } to confirm this isn't causing issues, same outcome.export async function handleLogin(){
await signIn('github')
}this is executed from my form component since the
signIn procedure/function cannot be imported inside client side components. if there's an alternative solution, do share.