Make OAuth URLs production-ready using NEXT_PUBLIC_APP_URL

- Remove hardcoded /leopost path from Google OAuth redirect
- Use environment variable for flexible deployment URL
- Fallback to window.location.origin for local development

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Michele
2026-01-31 19:46:06 +01:00
parent c561299ebd
commit af3b007a3e

View File

@@ -32,13 +32,16 @@ export function GoogleSignInButton() {
const [loading, setLoading] = useState(false)
const supabase = createClient()
// Use configured APP_URL for OAuth callback
const appUrl = process.env.NEXT_PUBLIC_APP_URL || window.location.origin
async function handleGoogleSignIn() {
setLoading(true)
const { error } = await supabase.auth.signInWithOAuth({
provider: 'google',
options: {
redirectTo: `${window.location.origin}/leopost/auth/callback/`,
redirectTo: `${appUrl}/auth/callback/`,
queryParams: {
access_type: 'offline',
prompt: 'consent',