Skip to content

Commit

Permalink
fix: remove 2 versions of cookie while logging out
Browse files Browse the repository at this point in the history
  • Loading branch information
olexh committed Dec 29, 2024
1 parent 1303603 commit dfdc521
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/app/(api)/auth/logout/route.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { cookies } from 'next/headers';
import { NextResponse } from 'next/server';

// export const dynamic = 'force-dynamic';

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

cookieStore.getAll().forEach((cookie) => {
cookieStore.delete(cookie);
// Видалення hostOnly кукі
const response = NextResponse.redirect(`${process.env.SITE_URL}`, {
headers: {
'Set-Cookie': 'auth=; Max-Age=0; Path=/; HttpOnly; SameSite=Lax',
},
});

(await cookies()).delete({
name: 'auth',
domain: process.env.COOKIE_DOMAIN,
httpOnly: process.env.COOKIE_HTTP_ONLY === 'true',
sameSite: 'lax',
});
// Видалення кукі з доменом
response.headers.append(
'Set-Cookie',
'auth=; Max-Age=0; Path=/; Domain=.hikka.io; HttpOnly; SameSite=Lax',
);

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

0 comments on commit dfdc521

Please sign in to comment.