fix: reload window on logout
This commit is contained in:
14
app/[lang]/(live)/(protected)/(.)logout/page.tsx
Normal file
14
app/[lang]/(live)/(protected)/(.)logout/page.tsx
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useEffect } from "react"
|
||||||
|
|
||||||
|
import LoadingSpinner from "@/components/LoadingSpinner"
|
||||||
|
|
||||||
|
export default function LogoutInterceptedRoute() {
|
||||||
|
// Reload the browser on logout in order to flush router cache. This is to make sure we don't show stale user specific data.
|
||||||
|
useEffect(() => {
|
||||||
|
window.location.reload()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return <LoadingSpinner />
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { revalidatePath } from "next/cache"
|
|
||||||
import { NextRequest, NextResponse } from "next/server"
|
import { NextRequest, NextResponse } from "next/server"
|
||||||
import { AuthError } from "next-auth"
|
import { AuthError } from "next-auth"
|
||||||
|
|
||||||
@@ -95,9 +94,6 @@ export async function GET(
|
|||||||
redirect: false,
|
redirect: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Revalidate the router cache for my pages to make sure we don't show stale user data
|
|
||||||
revalidatePath("/[lang]/my-pages", "layout")
|
|
||||||
|
|
||||||
if (redirectUrlObj) {
|
if (redirectUrlObj) {
|
||||||
console.log(`[logout] redirecting to: ${redirectUrlObj.redirect}`)
|
console.log(`[logout] redirecting to: ${redirectUrlObj.redirect}`)
|
||||||
return NextResponse.redirect(redirectUrlObj.redirect)
|
return NextResponse.redirect(redirectUrlObj.redirect)
|
||||||
|
|||||||
Reference in New Issue
Block a user