My app is running fine on my local env but after I deployed it on vercel, I am not able to sign in because it’s getting redirected to /api/auth/error
and displaying the following message:
“Server error
There is a problem with the server configuration.Check the server logs for more information.”
and the log message is
[GET] /api/auth/error?error=Configuration&nxtPnextauth=error status=500
I did some research online and found that we are required to add NEXTAUTH_SECRET key on production, which I have added now, but the issue still persists.
This is my auth.ts file:
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import NextAuth, { DefaultSession } from "next-auth";
import Google from "next-auth/providers/google";
import { database } from "@/db/database";
import { accounts, sessions, users, verificationTokens } from "@/db/schema";
import { env } from "@/env";
declare module "next-auth" {
interface Session {
user: {
id: string;
} & DefaultSession["user"];
}
}
export const { handlers, signIn, signOut, auth } = NextAuth({
adapter: DrizzleAdapter(database, {
usersTable: users,
accountsTable: accounts as any,
sessionsTable: sessions,
verificationTokensTable: verificationTokens,
}),
callbacks: {
session({ session, user }) {
session.user.id = user.id;
return session;
},
},
providers: [Google],
secret: process.env.NEXTAUTH_SECRET,
});
What am I doing wrong?
PS – I’m using NextAuth version 5.0.0-beta.19
Someone mentioned that I should set AUTH_TRUST_HOST="your-prod-url.com"
,
I have assigning https://auclify.vercel.app/
to it and when that didn’t work I also tried assigning true
to it(https://authjs.dev/getting-started/deployment#auth_trust_host), but the issue didn’t resolve