Skip to content

Commit

Permalink
fix: logout user(please work)
Browse files Browse the repository at this point in the history
  • Loading branch information
olexh committed Dec 29, 2024
1 parent f2c219d commit 8603e5d
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/app/(api)/auth/logout/route.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import { cookies } from 'next/headers';

export const dynamic = 'force-dynamic';
import { NextResponse } from 'next/server';

export async function GET() {
const cookieStore = await cookies();

try {
cookieStore.delete({
name: 'auth',
domain: process.env.COOKIE_DOMAIN,
});
const response = NextResponse.redirect(`${process.env.SITE_URL}`);

cookieStore.getAll().forEach((cookie) => {
cookieStore.delete(cookie.name);
});
} catch (e) {
console.error(e);
}
response.cookies.set('auth', '', {
path: '/',
expires: new Date(0),
});

return Response.redirect(`${process.env.SITE_URL}`);
return response;
}

0 comments on commit 8603e5d

Please sign in to comment.