JWJ
Convex Community12mo ago
2 replies
JW

Issue with Google Login in Production

Hi everyone, I’m experiencing an issue with Google login in my production environment.

Tech Stack:
- Next.js: 15.1
- Convex: 1.17.4
- @auth/core: 0.36.0 (downgraded from 0.37.0, but the issue persists)
- @convex-dev/auth: 0.0.78

Issue:
- Using Password, GitHub, and Google providers.
- All work fine in local dev, but in production, only Google login fails.
- Google users aren’t registered in Convex DB.

Relevant Code:
convex/auth.ts
import { convexAuth } from "@convex-dev/auth/server";
import { DataModel } from "./_generated/dataModel";
import { Password } from "@convex-dev/auth/providers/Password";
import GitHub from "@auth/core/providers/github";
import Google from "@auth/core/providers/google";

const CustomPassword = Password<DataModel>({
  profile(params) {
    return {
      email: params.email as string,
      name: params.name as string,
    };
  },
});

export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
  providers: [CustomPassword, GitHub, Google],
});


middleware.ts
import {
  convexAuthNextjsMiddleware,
  createRouteMatcher,
  nextjsMiddlewareRedirect,
} from "@convex-dev/auth/nextjs/server";

const isPublicPage = createRouteMatcher(["/auth"]);

export default convexAuthNextjsMiddleware(async (request, { convexAuth }) => {
  if (!isPublicPage(request) && !(await convexAuth.isAuthenticated())) {
    return nextjsMiddlewareRedirect(request, "/auth");
  }
  if (isPublicPage(request) && (await convexAuth.isAuthenticated())) {
    return nextjsMiddlewareRedirect(request, "/");
  }
});

export const config = {
  matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};


Troubleshooting:
- Downgraded @auth/core 0.37.0 to 0.36.0 – no effect.
- Verified OAuth credentials & callback URLs – all correct.

Anyone faced a similar issue? Could this be due to env variables, CORS, or OAuth config?

Thanks in advance! 🚀
Was this page helpful?