79388621

Date: 2025-01-26 13:52:48
Score: 0.5
Natty:
Report link

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"
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Aathi