js setup and I used next auth(Google OAuth) before publishing it to production it Google OAuth is perfectly working on local host, however when I tried to upload it on OVH VPS it always says after clicking the login it redirect me to ? and display the error below
Server error There is a problem with the server configuration.
Check the server logs for more information.
the current code that I have is for login for
import Image from "next/image";
import Link from "next/link";
import { FcGoogle } from "react-icons/fc";
import "./loginform.css";
import { auth, signIn } from "@/auth";
const LoginForm = async () => {
const session = await auth();
return (
<div className="login-wrapper">
<div className="login-container">
<Image
src={"/images/logo.png"}
alt="logo"
width={300}
height={300}
className="logo"
/>
<h1 className="login-title">Welcome Back</h1>
{session?.user ? (
<div className="logged-in-content">
<p>
You are already logged in as <span>{session.user.email}</span>
</p>
<Link href="/dashboard" className="dashboard-button">
Go to Dashboard
</Link>
</div>
) : (
<form
className="social-button google-button"
action={async () => {
"use server";
try {
await signIn("google");
} catch (error: unknown) {
if (
(error as { digest?: string })?.digest?.includes(
"NEXT_REDIRECT"
)
) {
throw error;
}
console.error("Login error:", error);
throw error;
}
}}
>
<FcGoogle size={24} />
<button type="submit">Login with Google</button>
</form>
)}
</div>
</div>
);
};
export default LoginForm;
and on the auth.ts setup I have this following codes
import NextAuth from "next-auth";
import Google from "next-auth/providers/google";
if (!process.env.AUTH_GOOGLE_ID || !process.env.AUTH_GOOGLE_SECRET) {
throw new Error("Missing Google OAuth credentials");
}
const allowedEmails = process.env.NEXT_PUBLIC_ALLOWED_EMAILS?.split(",") || [];
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [
Google({
clientId: process.env.AUTH_GOOGLE_ID,
clientSecret: process.env.AUTH_GOOGLE_SECRET,
}),
],
callbacks: {
async signIn({ profile }) {
try {
if (!profile?.email) return false;
return allowedEmails.includes(profile.email);
} catch (error) {
console.error("Sign-in error:", error);
return false;
}
},
},
secret: process.env.AUTH_SECRET,
});
Thank you so much