next-auth icon indicating copy to clipboard operation
next-auth copied to clipboard

Getting "Try signing in with a different account" on Vercel deployment but not in local environment

Open rael346 opened this issue 3 years ago • 0 comments

Question 💬

After using signIn with Google Provider, instead of redirecting to /onboard, the page redirects back to sign-in with this url: [main url]/sign-in?callbackUrl=https%3A%2F%2F[main url]%2Fonboard&error=Callback. This is only happening when I deploy this on Vercel, but doesn't happen in local environment.

How to reproduce ☕️

package.json

    "next": "12.2.4",
    "next-auth": "^4.10.3",
    "react": "18.2.0",

authOptions

export const authOptions: NextAuthOptions = {
  callbacks: {
    session({ session, user }) {
      if (session.user) {
        session.user.id = user.id;
        session.user.isOnboarded = user.isOnboarded;
      }
      return session;
    },
  },
  adapter: PrismaAdapter(prisma),
  providers: [
    GoogleProvider({
      clientId: process.env.GOOGLE_CLIENT_ID!,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
    }),
  ],
  pages: {
    signIn: "/sign-in",
  },
};

env

# Prisma

DATABASE_URL=xxx

# Next Auth

NEXTAUTH_SECRET=xxx
NEXTAUTH_URL=http://localhost:3000

# Next Auth Google Provider

GOOGLE_CLIENT_ID=xxx
GOOGLE_CLIENT_SECRET=xxx

Here is the current repo and it is deploy here

Contributing 🙌🏽

No, I am afraid I cannot help regarding this

rael346 avatar Aug 09 '22 00:08 rael346