OAuth sign in isn't redirecting on the server side
Last edited: 2/4/2025
The reason behind this limitation is that the auth helpers library lacks a direct mechanism for performing server-side redirects, as each framework handles redirects differently. However, the library does offer a URL through the data property it returns, which should be utilized for the purpose of redirection.
Next.js:
1import { NextResponse } from "next/server";2...3const { data } = await supabase.auth.signInWithOAuth({4 provider: 'github',5})67return NextResponse.redirect(data.url)SvelteKit:
1import { redirect } from '@sveltejs/kit';2...3const { data } = await supabase.auth.signInWithOAuth({4 provider: 'github',5})67throw redirect(303, data.url)Remix:
1import { redirect } from "@remix-run/node"; // or cloudflare/deno2...3const { data } = await supabase.auth.signInWithOAuth({4 provider: 'github',5})67return redirect(data.url)