Next Auth on Vercel encountered a server error
P粉420868294
P粉420868294 2024-03-21 22:04:29
0
1
518

I am using Google as the authentication provider for next authentication. Configure all environment variables in production and development. It runs perfectly in development mode on my local machine but in production it shows the error "Server Error There is a problem with the server configuration.

Whenever I try to log in, check the server logs for more information.

I deployed the website to vercel and set the google id, secret and NEXTAUTH_URL variables there.

This is the code I use

import NextAuth from "next-auth"
import GoogleProvider from 'next-auth/providers/google'
export const authOptions = { // Configure one or more authentication providers
  providers: [
    GoogleProvider({ 
      clientId: process.env.GOOGLE_ID, 
      clientSecret: process.env.GOOGLE_SECRET, }), // ...add more providers here
  ],
}

export default NextAuth(authOptions)

I tried adding all environment variables to vercel but it didn't work and I also redeployed several times

P粉420868294
P粉420868294

reply all(1)
P粉442576165

Maybe it has something to do with nextauth itself. Both secrets should be set on vercel:

jwt: {
    secret: process.env.JWT_SECRET,
  },
secret: process.env.SECRET,
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template