From bd7ec3ddded2aea3c2c565b568c2ec4cc80c332c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o?= <43091603+glazk0@users.noreply.github.com> Date: Wed, 26 Apr 2023 13:54:52 +0200 Subject: [PATCH] Fix logout --- app/logout/page.tsx | 9 ++++++++- middleware.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/logout/page.tsx b/app/logout/page.tsx index 7a93d87..96e3e7b 100644 --- a/app/logout/page.tsx +++ b/app/logout/page.tsx @@ -1,7 +1,14 @@ +'use client'; + import { useRouter } from 'next/navigation'; +import { useEffect } from 'react'; export default function Page() { const router = useRouter(); - router.push('/'); + + useEffect(() => { + router.push('/'); + }, []); + return <>; } diff --git a/middleware.ts b/middleware.ts index 48f542c..27ea001 100644 --- a/middleware.ts +++ b/middleware.ts @@ -26,7 +26,7 @@ export async function middleware(req: NextRequest) { return res; } - if (isAuth && req.nextUrl.pathname.includes('logout')) { + if (isAuth && req.nextUrl.pathname === '/logout') { res.cookies.set('token', '', { path: '/', expires: new Date(0)