Next.js Discord

Discord Forum

Error: localhost is currently unable to handle this request.HTTP ERROR 500

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
Hi, i'm struggling with Google Authentication Sign In feature. I still cannot spot any errors from my code.

// import stuffs
declare module "next-auth" {
  interface Session extends DefaultSession {
    user: {
      id: string;
      // ...other properties
      // role: UserRole;
    } & DefaultSession["user"];
  }
export const authConfig = {
  debug: true,
  providers: [
    GoogleProvider({
      clientId: process.env.GOOGLE_CLIENT_ID,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET,
    }),
    GithubProvider({
      clientId: process.env.GITHUB_CLIENT_ID,
      clientSecret: process.env.GITHUB_CLIENT_SECRET,
    }),
    CredentialsProvider({
      name: "sign in",
      credentials: {
        email: {
          label: "Email",
          type: "email",
          placeholder: "example@gmail.com",
        },
        password: { label: "Password", type: "password" },  
      },
      async authorize(credentials) {
        if (!credentials?.email || !credentials.password) {
          return null;
        }

        const dbUser = await db.user.findFirst({
          where: { email: credentials.email },
        })

        if (dbUser && dbUser.password === credentials.password) {
          const { password, id, ...dbUserWithoutPassword } = dbUser;
          return dbUserWithoutPassword as User;
        }
        return null;
      }
    }),
  ],
  pages: {
    signIn: "/auth/signin",
    error: "/auth/error",
  },
  secret: process.env.NEXTAUTH_SECRET,
  adapter: PrismaAdapter(db) as Adapter, 
  callbacks: {
    session: ({ session, user }) => ({
      ...session,
      user: {
        ...session.user,
        id: user.id,
      },
    }),
    
  // rest
} satisfies NextAuthConfig;

3 Replies

you should check your terminal
Brown bearOP
 GET /api/auth/providers 500 in 152ms
 ⨯ [TypeError: Function.prototype.apply was called on #<Object>, which is an object and not a function]