23 lines
503 B
JavaScript
23 lines
503 B
JavaScript
// app/api/clearCookies/route.js
|
|
import { cookies } from "next/headers";
|
|
|
|
export async function POST() {
|
|
const cookieStore = cookies();
|
|
const allCookies = cookieStore.getAll();
|
|
|
|
// Loop through all cookies and clear them
|
|
allCookies.forEach(({ name }) => {
|
|
cookieStore.set({
|
|
name,
|
|
value: "",
|
|
path: "/",
|
|
maxAge: 0,
|
|
httpOnly: true,
|
|
secure: true,
|
|
sameSite: "lax",
|
|
});
|
|
});
|
|
|
|
return new Response("Cookies cleared successfully", { status: 200 });
|
|
}
|