Skip to content

Commit

Permalink
importing supabase from ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
Interperle committed Nov 7, 2023
1 parent 35ca2cc commit 937d381
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions frontend/src/app/auth/callback/route.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
import { createRouteHandlerClient } from '@supabase/auth-helpers-nextjs'
import { cookies } from 'next/headers'
import { NextResponse } from 'next/server'
import { supabase } from "@/utils/supabase_route";
import { NextResponse } from "next/server";

import type { NextRequest } from 'next/server'
import type { Database } from '@/types/supabase'

export async function GET(request: NextRequest) {
const requestUrl = new URL(request.url)
const code = requestUrl.searchParams.get('code')
export async function GET(request: Request) {
const requestUrl = new URL(request.url);
const code = requestUrl.searchParams.get("code");

if (code) {
const cookieStore = cookies()
const supabase = createRouteHandlerClient<Database>({ cookies: () => cookieStore })
await supabase.auth.exchangeCodeForSession(code)
}

const next = requestUrl.searchParams.get('next')
if (next) {
return NextResponse.redirect(next)
await supabase.auth.exchangeCodeForSession(code);
}

// URL to redirect to after sign in process completes
return NextResponse.redirect(requestUrl.origin)
return NextResponse.redirect(requestUrl.origin);
}

0 comments on commit 937d381

Please sign in to comment.