JW
JW3w ago

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],
});
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)(.*)"],
};
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! 🚀
2 Replies
Convex Bot
Convex Bot3w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
ballingt
ballingt3w ago
Say more about the error, what happens? Are there error messages in the convex logs or in the browser? See this on debugging https://labs.convex.dev/auth/debugging
Debugging - Convex Auth
Authentication library for your Convex backend

Did you find this page helpful?