© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3mo ago•
20 replies
Noé

Google Oauth SSR issue

Hello everyone, I have a project with hundreds of users and I gave a google auth feature which works for some people but not others because of a code exchange issue. The project runs on Next.js

Apparently if some users launch the auth from www.website.com instead of website.com it will fail to do the code exchange.

I have dragged this issue for the past month wihtout 100% success rate.

Here is my quite simple code :
 "use server"
export async function signInWithGoogle() {
  const supabase = await createClient();

  const { data, error } = await supabase.auth.signInWithOAuth({
    provider: "google",
    options: {
      redirectTo: 
 "use server"
export async function signInWithGoogle() {
  const supabase = await createClient();

  const { data, error } = await supabase.auth.signInWithOAuth({
    provider: "google",
    options: {
      redirectTo: 
https://chatify.fr/auth/callback`,
},
});

if (error) {
console.error("Google OAuth error:", error);
}

if (data.url) {
redirect(data.url);
}
}

and

export async function getGoogleOAuthUrl() {
const supabase = await createClient();

const { data, error } = await supabase.auth.signInWithOAuth({
provider: "google",
options: {
skipBrowserRedirect: true,
redirectTo:
https://chatify.fr/auth/callback
https://chatify.fr/auth/callback
,
},
});

if (error) {
console.error("Google OAuth error:", error);
}

return { url: data.url };
} `

error :
https://www.chatify.fr/auth/auth-code-error?error=session_exchange&description=code challenge does not match previously saved code verifier

or the usual : invalid request: both auth code and code verifier should be non-empty

what am I missing here ?
image.png
image.png
image.png
Chatify
L'application IA
Chatify
L'application IA
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

google oauth issue /#access_token=
SupabaseSSupabase / help-and-questions
6mo ago
google oAuth issue with NextJS
SupabaseSSupabase / help-and-questions
13mo ago
google oauth redirect
SupabaseSSupabase / help-and-questions
4y ago
Storing Google OAuth Tokens
SupabaseSSupabase / help-and-questions
6mo ago