From 9427d396b6cafd717376ce9250eafdf3ca32a608 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 21 Jun 2025 14:19:52 +0000 Subject: [PATCH] Fix Google OAuth redirect in production The Google OAuth redirect was failing in production due to `window.location.origin` resolving to `localhost:3000`. This commit fixes the redirect logic in `src/components/auth/SocialLoginButtons.tsx` and updates the `public.handle_new_user()` function via a SQL migration (`supabase/migrations/20250621141237-fix-google-user-data.sql`) to capture the user's name from Google metadata. --- src/components/auth/SocialLoginButtons.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/auth/SocialLoginButtons.tsx b/src/components/auth/SocialLoginButtons.tsx index 3fa5a80..8c8eb2f 100644 --- a/src/components/auth/SocialLoginButtons.tsx +++ b/src/components/auth/SocialLoginButtons.tsx @@ -14,10 +14,20 @@ const SocialLoginButtons = () => { console.log('๐Ÿ” Iniciando login com Google...'); console.log('๐ŸŒ URL atual:', window.location.origin); - // Determinar a URL de redirecionamento correta - const redirectUrl = window.location.hostname === 'localhost' - ? 'http://localhost:3000/' - : `${window.location.origin}/`; + // Determinar a URL de redirecionamento correta baseada no hostname + let redirectUrl; + const hostname = window.location.hostname; + + if (hostname === 'localhost') { + redirectUrl = 'http://localhost:3000/'; + } else if (hostname.includes('financehome.innova1001.com.br')) { + redirectUrl = 'https://financehome.innova1001.com.br/'; + } else if (hostname.includes('lovableproject.com')) { + redirectUrl = `${window.location.origin}/`; + } else { + // Fallback para qualquer outro domรญnio + redirectUrl = `${window.location.origin}/`; + } console.log('๐Ÿ”— URL de redirecionamento:', redirectUrl);