I am having this problem when deploying my site in Vercel, in localhsot it works excellent.enter image description here
I also tried separating authOptions into an auth.ts component but it didn’t work either and gave me this error
enter image description here
Currently this is how my route.ts is: srcappapiauth[…nextauth]
import { SupabaseAdapter } from "@auth/supabase-adapter";
import { NextAuthOptions } from "next-auth";
import { Adapter } from "next-auth/adapters";
import { getUserData, signInEmailPassword } from '../../../../../lib/next-auth/actions';
import NextAuth from 'next-auth'
import GoogleProvider from "next-auth/providers/google";
import CredentialsProvider from "next-auth/providers/credentials";
export const authOptions: NextAuthOptions = {
adapter: SupabaseAdapter({
url: process.env.NEXT_PUBLIC_SUPABASE_URL!,
secret: process.env.NEXT_PUBLIC_SUPABASE_SERVICE_ROLE_KEY!,
}) as Adapter,
providers: [
GoogleProvider({
clientId: process.env.AUTH_GOOGLE_ID!,
clientSecret: process.env.AUTH_GOOGLE_SECRET!,
}),
CredentialsProvider({
name: "Credentials",
credentials: {
email: { label: "Correo electrónico", type: "email", placeholder: "[email protected]" },
password: { label: "Contraseña", type: "password", placeholder: '******' }
},
async authorize(credentials, req) {
const user = await signInEmailPassword(credentials!.email, credentials!.password)
if (user) {
return user;
}
return null;
}
}),
],
secret: process.env.AUTH_SECRET,
session: {
strategy: 'jwt',
},
callbacks: {
async signIn({ user, account, profile, email, credentials }) {
return true;
},
async jwt({ token, user, account, profile }) {
const dbUser = await getUserData(token.email);
token.rol = dbUser?.rol ?? 'no-rol';
token.id = dbUser?.id ?? 'no-uuid';
return token;
},
async session({ session, token, user }) {
if (session && session.user) {
session.user.rol = token.rol;
session.user.id = token.id;
}
return session;
},
},
};
const handler = NextAuth(authOptions)
export { handler as GET, handler as POST }```