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:
_10import { NextResponse } from "next/server";_10..._10const { data } = await supabase.auth.signInWithOAuth({_10 provider: 'github',_10})_10_10return NextResponse.redirect(data.url)
SvelteKit:
_10import { redirect } from '@sveltejs/kit';_10..._10const { data } = await supabase.auth.signInWithOAuth({_10 provider: 'github',_10})_10_10throw redirect(303, data.url)
Remix:
_10import { redirect } from "@remix-run/node"; // or cloudflare/deno_10..._10const { data } = await supabase.auth.signInWithOAuth({_10 provider: 'github',_10})_10_10return redirect(data.url)