mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
docs: fix bug in ssr guide email flow pkce (#19281)
This commit is contained in:
1 parent
fe053fffb1
commit
d5340a94a8
1 file changed
+7
-4
@@ -31,13 +31,15 @@ Create a new file at `app/auth/confirm/route.ts` and populate with the following
|
||||
import { createServerClient, type CookieOptions } from '@supabase/ssr'
|
||||
import { type EmailOtpType } from '@supabase/supabase-js'
|
||||
import { cookies } from 'next/headers'
|
||||
import { NextResponse } from 'next/server'
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
|
||||
export async function GET(request: Request) {
|
||||
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 redirectTo = request.nextUrl.clone()
|
||||
redirectTo.pathname = next
|
||||
|
||||
if (token_hash && type) {
|
||||
const cookieStore = cookies()
|
||||
@@ -64,12 +66,13 @@ export async function GET(request: Request) {
|
||||
token_hash,
|
||||
})
|
||||
if (!error) {
|
||||
return NextResponse.redirect(next)
|
||||
return NextResponse.redirect(redirectTo)
|
||||
}
|
||||
}
|
||||
|
||||
// return the user to an error page with some instructions
|
||||
return NextResponse.redirect('/auth/auth-code-error')
|
||||
redirectTo.pathname = '/auth/auth-code-error'
|
||||
return NextResponse.redirect(redirectTo)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in new issue
Block a user