Add Google sign-in functionality to Login and Register pages, including error handling and UI updates for better user experience.

This commit is contained in:
2025-04-23 20:52:04 +08:00
parent ced29201da
commit 0203cb4041
5 changed files with 159 additions and 24 deletions

View File

@@ -0,0 +1,17 @@
import { createRouteHandlerClient } from '@supabase/auth-helpers-nextjs';
import { cookies } from 'next/headers';
import { NextRequest, NextResponse } from 'next/server';
export async function GET(request: NextRequest) {
const requestUrl = new URL(request.url);
const code = requestUrl.searchParams.get('code');
if (code) {
const cookieStore = cookies();
const supabase = createRouteHandlerClient({ cookies: () => cookieStore });
await supabase.auth.exchangeCodeForSession(code);
}
// URL to redirect to after sign in process completes
return NextResponse.redirect(new URL('/analytics', request.url));
}