If your port is different from 3000, you need to update the config
import NextAuth from "next-auth";
import GoogleProvider from "next-auth/providers/google";
const handler = NextAuth({
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
authorization: {
params: {
response_type: "code",
redirect_uri: "http://localhost:5000/api/auth/callback/google",
scope: "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"
}
}
})
]
});
export { handler as GET, handler as POST }
Update .env
NEXTAUTH_URL="http://localhost:3001"