Skip to content

Commit

Permalink
chore(webapp): handle error on logout (#222)
Browse files Browse the repository at this point in the history
- handle error that supabase may throw during logout
  • Loading branch information
detj authored Nov 21, 2023
1 parent 23a268a commit e85505e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions measure-web-app/app/auth/logout/route.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import { createClient } from '@/utils/supabase/server'
import { NextResponse} from 'next/server'
import { NextResponse } from 'next/server'

export const dynamic = 'force-dynamic'

export async function GET(request: Request) {
const requestUrl = new URL(request.url)
const supabase = createClient()

await supabase.auth.signOut()
const { error } = await supabase.auth.signOut()

if (error) {
console.log(`logout failed with error`, error)
}

return NextResponse.redirect(`${requestUrl.origin}/auth/login`, {
status: 301,
// using temporary redirect, so that browsers don't cache this
// redirection
status: 302,
})
}

0 comments on commit e85505e

Please sign in to comment.