redirect_uri_mismatch with Supabase Google or GitHub login – which URL goes where

By Abheesht Tripathi · Published

Error 400: redirect_uri_mismatch
The redirect_uri MUST match the registered callback URL for this application.

What it means

In an OAuth login, the provider (Google, GitHub, Apple, Microsoft) sends the user back to a redirect URI after they approve. The provider only accepts URIs you registered in its console. With Supabase Auth, the redirect URI the provider sees is Supabase's callback, not your app. If that exact URL isn't registered, Google shows Error 400: redirect_uri_mismatch and GitHub returns “The redirect_uri MUST match the registered callback URL for this application.”

Two different URLs, two different places

URLExampleRegister it in
Supabase callback (provider → Supabase)https://<project-ref>.supabase.co/auth/v1/callback Google Cloud console: Authorized redirect URIs. GitHub OAuth app: Authorization callback URL.
Your app (Supabase → your app)https://app.example.com/auth/callback Supabase: Authentication → URL Configuration → Redirect URLs.

The classic mistake is putting https://app.example.com/auth/callback into Google. Google never sends users there; Supabase does.

Fix, step by step

  1. Open the provider's page in the Supabase dashboard (Authentication → Sign In / Providers → Google). Copy the Callback URL shown there.
  2. Paste it exactly into the provider console. For Google: the OAuth client's Authorized redirect URIs. Under Authorized JavaScript origins put only your site's origin, such as https://app.example.com, with no path.
  3. Compare character by character: https vs http, trailing slash, and the project ref. Google says changes can take 5 minutes to a few hours to apply.
  4. If you use a Supabase custom domain, the provider sees https://auth.example.com/auth/v1/callback instead. Register that one (you can keep both while you switch).
  5. For local development with the Supabase CLI, register http://127.0.0.1:54321/auth/v1/callback in a separate development OAuth client.

GitHub allows one callback URL per OAuth app

A GitHub OAuth app has a single Authorization callback URL. Create one app for local development and one for production, each with its own client id and secret, and set them in the matching Supabase project or local config.

Then send users back to your app

const { error } = await supabase.auth.signInWithOAuth({
  provider: 'google',
  options: { redirectTo: `${window.location.origin}/auth/callback` },
});

redirectTo must be on the Supabase Redirect URLs allow list. If it isn't, the login succeeds but the user lands on your Site URL instead. With the server-side (PKCE) flow, your /auth/callback route exchanges the code:

// app/auth/callback/route.ts
import { NextResponse } from 'next/server';
import { createClient } from '@/utils/supabase/server';

export async function GET(request: Request) {
  const { searchParams, origin } = new URL(request.url);
  const code = searchParams.get('code');
  if (code) {
    const supabase = await createClient();
    const { error } = await supabase.auth.exchangeCodeForSession(code);
    if (!error) return NextResponse.redirect(`${origin}/dashboard`);
  }
  return NextResponse.redirect(`${origin}/auth/error`);
}

How to verify

Start the login in a private window. The provider's consent screen appears (no error page), you return through …/auth/v1/callback, and you land on /dashboard on your own domain with a session. Repeat on a Vercel preview URL if you use them: the preview pattern must be on the Supabase allow list, but nothing changes in Google.

Related guides

More in Auth, JWT and secrets · all guides