Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I’m using NextAuth.js with a custom base path /api/v1/auth.
Everything works perfectly in local development, but in production (Vercel) I get a Google OAuth error: redirect_uri_mismatch even though the redirect URL in the Google Cloud Console matches exactly what NextAuth generates locally.

Environment

  • Framework: Next.js 15
  • Auth library: next-auth@4.24.11
  • Deployment: Vercel
  • Provider: Google OAuth

.env

NEXTAUTH_URL="https://mydomain.vercel.app/api/v1/auth"
NEXTAUTH_SECRET="super-secret"

app/provider.ts

"use client";
import { SessionProvider } from "next-auth/react";

export default function AppProvider({
	children,
}: {
	children: React.ReactNode;
}) {
	return (
		<SessionProvider basePath="/api/v1/auth">
			<ThemeProvider
				attribute="class"
				defaultTheme="light"
				enableSystem
				disableTransitionOnChange
			>
				{children}
			</ThemeProvider>
		</SessionProvider>
	);
}

File structure
/app/api/v1/auth/[...nextauth]/route.ts

Expected Behavior
Google OAuth should redirect correctly to:
https://mydomain..vercel.app/api/v1/auth/callback/google

Actual Behavior
After sign-in, the redirect URL generated by NextAuth is:
https://mydomain..vercel.app/api/auth/callback/google

Images
Screenshot 2025-10-05 002331
Screenshot 2025-10-05 002558
Screenshot 2025-10-05 015220

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Help
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.