diff --git a/app/(marketing)/components/auth-code-handler.tsx b/app/(marketing)/components/auth-code-handler.tsx new file mode 100644 index 0000000..579bb28 --- /dev/null +++ b/app/(marketing)/components/auth-code-handler.tsx @@ -0,0 +1,38 @@ +'use client' + +import { useEffect } from 'react' +import { useSearchParams, useRouter } from 'next/navigation' + +/** + * Auth Code Handler + * + * Handles auth codes that Supabase redirects to the home page + * Redirects to /auth/callback to process the code exchange + */ +export function AuthCodeHandler() { + const searchParams = useSearchParams() + const router = useRouter() + const code = searchParams.get('code') + const type = searchParams.get('type') + + useEffect(() => { + if (code) { + // Build callback URL with all parameters + const callbackUrl = new URL('/auth/callback', window.location.origin) + callbackUrl.searchParams.set('code', code) + if (type) { + callbackUrl.searchParams.set('type', type) + } + // If it's a recovery flow, ensure we redirect to update-password + if (type === 'recovery') { + callbackUrl.searchParams.set('next', '/update-password') + } + + // Redirect to callback route + router.replace(callbackUrl.pathname + callbackUrl.search) + } + }, [code, type, router]) + + return null +} + diff --git a/app/(marketing)/page.tsx b/app/(marketing)/page.tsx index f7e530a..37440fa 100644 --- a/app/(marketing)/page.tsx +++ b/app/(marketing)/page.tsx @@ -18,6 +18,7 @@ import type { MetadataContent } from '@/content/schemas/manifesto' import { HeroSectionClient } from './components/hero-section-client' import { BuildTimeline } from './components/build-timeline' import { WhyMe } from '@/components/ui/why-me' +import { AuthCodeHandler } from './components/auth-code-handler' // Generate metadata for SEO export async function generateMetadata(): Promise { @@ -134,6 +135,9 @@ export default async function HomePage() { return ( <> + {/* Handle auth codes that Supabase redirects to home page */} + + {/* Hero Section */}