<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: AI App Medic</title>
    <description>The latest articles on DEV Community by AI App Medic (@aiappmedic).</description>
    <link>https://dev.to/aiappmedic</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4267171%2Fdf411096-2059-4440-b15a-7394baf902e7.png</url>
      <title>DEV Community: AI App Medic</title>
      <link>https://dev.to/aiappmedic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aiappmedic"/>
    <language>en</language>
    <item>
      <title>Fix Google redirect_uri_mismatch with Supabase Auth</title>
      <dc:creator>AI App Medic</dc:creator>
      <pubDate>Fri, 27 Nov 2026 18:37:31 +0000</pubDate>
      <link>https://dev.to/aiappmedic/fix-google-redirecturimismatch-with-supabase-auth-22hh</link>
      <guid>https://dev.to/aiappmedic/fix-google-redirecturimismatch-with-supabase-auth-22hh</guid>
      <description>&lt;p&gt;The user clicks Sign in with Google, a Google page appears, and it stops with &lt;strong&gt;Error 400: redirect_uri_mismatch&lt;/strong&gt;. They never reach your Lovable, Bolt, or Cursor app. Google is rejecting the callback URL before Supabase issues a session. This is not a broken button, and it is not the same as a login that works and then drops the user on &lt;code&gt;localhost:3000&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Google is actually checking
&lt;/h2&gt;

&lt;p&gt;Your app calls &lt;code&gt;supabase.auth.signInWithOAuth({ provider: "google" })&lt;/code&gt;. Supabase sends the browser to Google with your project's Client ID and a &lt;code&gt;redirect_uri&lt;/code&gt;. That URI is Supabase's own callback, normally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://YOUR_PROJECT_REF.supabase.co/auth/v1/callback
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Google continues only if that exact string is listed under Authorized redirect URIs on the same OAuth client. Scheme, host, path, and trailing slash all have to match. Your app address, such as &lt;code&gt;https://your-app.lovable.app/auth/callback&lt;/code&gt; or &lt;code&gt;https://www.example.com&lt;/code&gt;, is not what Google checks, so adding only that address does not fix the error.&lt;/p&gt;

&lt;p&gt;After Google accepts the callback, Supabase signs the user in and sends them to your &lt;code&gt;redirectTo&lt;/code&gt; URL, or to the project's Site URL. That second hop is configured in Supabase, not in Google.&lt;/p&gt;

&lt;h2&gt;
  
  
  Copy the URI from the error, not from memory
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Reproduce the error and open Error details (sometimes labelled Request details). You should see a line like &lt;code&gt;redirect_uri=https://abcd1234.supabase.co/auth/v1/callback&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;You can also read it from the address bar. The Google URL contains &lt;code&gt;redirect_uri=&lt;/code&gt; in encoded form: &lt;code&gt;https://&lt;/code&gt; shows up as &lt;code&gt;https%3A%2F%2F&lt;/code&gt;. Decode it once.&lt;/li&gt;
&lt;li&gt;Paste that string into Google character for character. Do not add a trailing slash or swap the project ref for your app domain.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Edit the client whose ID is in Supabase
&lt;/h2&gt;

&lt;p&gt;In Supabase, open Authentication, Providers, Google, and copy the Client ID (it looks like &lt;code&gt;.apps.googleusercontent.com&lt;/code&gt;). In Google Cloud, open Google Auth Platform, then Clients, and open the client whose ID is identical. Check the project picker at the top; it is easy to be in the wrong Google Cloud project.&lt;/p&gt;

&lt;p&gt;The client type must be Web application. An iOS, Android, or Chrome extension client will not accept this callback, and a second web client will not help if Supabase still has the first client's ID and secret.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add the callback under Authorized redirect URIs
&lt;/h2&gt;

&lt;p&gt;On that client, under Authorized redirect URIs, add the callback from the Supabase Google provider page. It should match what you copied above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://YOUR_PROJECT_REF.supabase.co/auth/v1/callback
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No trailing slash. Use &lt;code&gt;https&lt;/code&gt;. For the Supabase CLI locally, the docs use &lt;code&gt;http://127.0.0.1:54321/auth/v1/callback&lt;/code&gt;. Google allows plain &lt;code&gt;http&lt;/code&gt; only for localhost addresses.&lt;/p&gt;

&lt;p&gt;If a Supabase custom domain is active, Auth advertises that host as the callback. Add both:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://YOUR_PROJECT_REF.supabase.co/auth/v1/callback
https://auth.example.com/auth/v1/callback
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use your real custom domain in the second line (commonly &lt;code&gt;auth.example.com&lt;/code&gt; or &lt;code&gt;api.example.com&lt;/code&gt;). Save the client. Google can take from a few minutes up to a few hours to apply the change, so an immediate failed test is not proof the URI is still wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  Put your app URL in the two places it does belong
&lt;/h2&gt;

&lt;p&gt;Your app origin goes in these two places, not in Google's redirect URI list:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Google, Authorized JavaScript origins:&lt;/strong&gt; &lt;code&gt;https://your-app.com&lt;/code&gt;, plus &lt;code&gt;https://www.your-app.com&lt;/code&gt; if you serve both, plus your &lt;code&gt;.lovable.app&lt;/code&gt; or &lt;code&gt;.bolt.host&lt;/code&gt; preview origin while you still use it. Origin only: no path, no trailing slash. A mistake here produces a different error, &lt;code&gt;origin_mismatch&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Supabase, Authentication, URL Configuration, Redirect URLs:&lt;/strong&gt; the page users return to, for example &lt;code&gt;https://your-app.com/auth/callback&lt;/code&gt;, plus the same path on &lt;code&gt;www&lt;/code&gt; and on the preview host. Set Site URL to your production origin, not &lt;code&gt;http://localhost:3000&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the app, pass that return URL explicitly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;supabase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signInWithOAuth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"google"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;redirectTo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;origin&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"/auth/callback"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you just added a custom domain, confirm the new origin is in the Redirect URLs list, and that Google has the new Supabase callback.&lt;/p&gt;

&lt;h2&gt;
  
  
  If Google succeeds but the app still shows you as logged out
&lt;/h2&gt;

&lt;p&gt;The mismatch error is gone, so the Google client is fine. Usual leftovers: the return URL is missing from Supabase Redirect URLs (Auth falls back to Site URL, often still localhost), &lt;code&gt;redirectTo&lt;/code&gt; still has an old preview origin, or a server-rendered callback (v0, Next.js) never calls &lt;code&gt;exchangeCodeForSession&lt;/code&gt;. If the consent screen is in Testing and the account is not a test user, you get an access blocked message, not &lt;code&gt;redirect_uri_mismatch&lt;/code&gt;. If the user returns with &lt;code&gt;error_description=Database+error+saving+new+user&lt;/code&gt; in the URL, a trigger on &lt;code&gt;auth.users&lt;/code&gt; failed. If Supabase could not exchange the external code, re-copy the client secret from the same Web application client.&lt;/p&gt;

&lt;p&gt;When you create a new Google client, paste the callback from the Supabase provider page first. When you add a production or Supabase custom domain, update Google and Supabase together.&lt;/p&gt;

&lt;p&gt;The full guide is at &lt;a href="https://aiappmedic.com/guides/supabase-google-oauth-redirect-uri-mismatch" rel="noopener noreferrer"&gt;https://aiappmedic.com/guides/supabase-google-oauth-redirect-uri-mismatch&lt;/a&gt; . You can also run a free scan of your app at &lt;a href="https://aiappmedic.com/scan" rel="noopener noreferrer"&gt;https://aiappmedic.com/scan&lt;/a&gt; .&lt;/p&gt;

</description>
      <category>supabase</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
