-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(webapp): handle error on logout (#222)
- handle error that supabase may throw during logout
- Loading branch information
Showing
1 changed file
with
9 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}) | ||
} |