Next.js Discord

Discord Forum

Supabase server client OAuth methods not working

Unanswered
American Pipit posted this in #help-forum
Open in Discord
Avatar
American PipitOP
export const signUpWithGoogle = async () => {
    'use server';
    const cookieStore = cookies();

    const serverSupabase = createServerClient<Database>(
        process.env.NEXT_PUBLIC_SUPABASE_URL!,
        process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
        {
            cookies: {
                get(name: string) {
                    return cookieStore.get(name)?.value;
                },
                set(name: string, value: string, options: CookieOptions) {
                    cookieStore.set({ name, value, ...options });
                },
                remove(name: string, options: CookieOptions) {
                    cookieStore.delete({ name, ...options });
                },
            },
        }
    );

    const {data, error} = await serverSupabase.auth.signInWithOAuth({
        provider: 'google',
        options: { redirectTo: `${getURL()}/auth/callback` },
    });
};


this is my server action, most of the other auth stuff is from the supabase docs. When I log data, it shows {url: someUrl, provider: google}, and when I manually go to that URL, it's actually the google sign in the function should redirect the user to.

0 Replies