Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(ui library): fix redirects (#36118)

Charis62fbe17a5e8c
diff --git a/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/app/auth/confirm/route.ts b/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/app/auth/confirm/route.ts
index 141bec92115..bfcd61eabc9 100644
--- a/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/app/auth/confirm/route.ts
+++ b/apps/ui-library/registry/default/blocks/password-based-auth-nextjs/app/auth/confirm/route.ts
@@ -7,7 +7,8 @@ export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url)
const token_hash = searchParams.get('token_hash')
const type = searchParams.get('type') as EmailOtpType | null
- const next = searchParams.get('next') ?? '/'
+ const _next = searchParams.get('next')
+ const next = _next?.startsWith('/') ? _next : '/'
if (token_hash && type) {
const supabase = await createClient()
diff --git a/apps/ui-library/registry/default/blocks/password-based-auth-react-router/app/routes/auth.confirm.tsx b/apps/ui-library/registry/default/blocks/password-based-auth-react-router/app/routes/auth.confirm.tsx
index 41425222c4f..37c751afc31 100644
--- a/apps/ui-library/registry/default/blocks/password-based-auth-react-router/app/routes/auth.confirm.tsx
+++ b/apps/ui-library/registry/default/blocks/password-based-auth-react-router/app/routes/auth.confirm.tsx
@@ -6,7 +6,8 @@ export async function loader({ request }: LoaderFunctionArgs) {
const requestUrl = new URL(request.url)
const token_hash = requestUrl.searchParams.get('token_hash')
const type = requestUrl.searchParams.get('type') as EmailOtpType | null
- const next = requestUrl.searchParams.get('next') || '/'
+ const _next = requestUrl.searchParams.get('next')
+ const next = _next?.startsWith('/') ? _next : '/'
if (token_hash && type) {
const { supabase, headers } = createClient(request)
diff --git a/apps/ui-library/registry/default/blocks/password-based-auth-tanstack/routes/auth/confirm.ts b/apps/ui-library/registry/default/blocks/password-based-auth-tanstack/routes/auth/confirm.ts
index 8e72087fc68..dcc07af3a14 100644
--- a/apps/ui-library/registry/default/blocks/password-based-auth-tanstack/routes/auth/confirm.ts
+++ b/apps/ui-library/registry/default/blocks/password-based-auth-tanstack/routes/auth/confirm.ts
@@ -27,7 +27,8 @@ const confirmFn = createServerFn({ method: 'GET' })
const searchParams = ctx.data
const token_hash = searchParams['token_hash'] as string
const type = searchParams['type'] as EmailOtpType | null
- const next = (searchParams['next'] ?? '/') as string
+ const _next = searchParams['next'] as string
+ const next = _next?.startsWith('/') ? _next : '/'
if (token_hash && type) {
const supabase = createClient()
diff --git a/apps/ui-library/registry/default/blocks/social-auth-react-router/app/routes/auth.oauth.tsx b/apps/ui-library/registry/default/blocks/social-auth-react-router/app/routes/auth.oauth.tsx
index cfe4dd1fd19..22da5434422 100644
--- a/apps/ui-library/registry/default/blocks/social-auth-react-router/app/routes/auth.oauth.tsx
+++ b/apps/ui-library/registry/default/blocks/social-auth-react-router/app/routes/auth.oauth.tsx
@@ -4,7 +4,8 @@ import { type LoaderFunctionArgs, redirect } from 'react-router'
export async function loader({ request }: LoaderFunctionArgs) {
const requestUrl = new URL(request.url)
const code = requestUrl.searchParams.get('code')
- const next = requestUrl.searchParams.get('next') || '/'
+ const _next = requestUrl.searchParams.get('next')
+ const next = _next?.startsWith('/') ? _next : '/'
if (code) {
const { supabase, headers } = createClient(request)
diff --git a/apps/ui-library/registry/default/blocks/social-auth-tanstack/routes/auth/oauth.ts b/apps/ui-library/registry/default/blocks/social-auth-tanstack/routes/auth/oauth.ts
index 8e72087fc68..2996a594a65 100644
--- a/apps/ui-library/registry/default/blocks/social-auth-tanstack/routes/auth/oauth.ts
+++ b/apps/ui-library/registry/default/blocks/social-auth-tanstack/routes/auth/oauth.ts
@@ -27,7 +27,8 @@ const confirmFn = createServerFn({ method: 'GET' })
const searchParams = ctx.data
const token_hash = searchParams['token_hash'] as string
const type = searchParams['type'] as EmailOtpType | null
- const next = (searchParams['next'] ?? '/') as string
+ const _next = (searchParams['next'] ?? '/') as string
+ const next = _next?.startsWith('/') ? _next : '/'
if (token_hash && type) {
const supabase = createClient()