// import { NextResponse } from 'next/server'; // import { cookies } from 'next/headers'; // export async function POST() { // try { // // Get the cookie store // const cookieStore = cookies(); // // Delete the d4a_uid cookie // cookieStore.delete('d4a_uid'); // // Return a successful response // return NextResponse.json({ message: 'Logged out successfully' }, { status: 200 }); // } catch (error) { // console.error('Logout error:', error); // // Return an error response if something goes wrong // return NextResponse.json({ message: 'Logout failed' }, { status: 500 }); // } // } import { NextResponse } from 'next/server'; import { cookies } from 'next/headers'; export async function POST() { try { const cookieStore = cookies(); const cookieOptions = { path: '/', secure: process.env.NODE_ENV === 'production', httpOnly: true, sameSite: 'lax' as const, expires: new Date(0), // Set to a past date to expire the cookie }; // Expire cookies to delete them cookieStore.set('d4a_session', '', cookieOptions); cookieStore.set('d4a_exp', '', cookieOptions); cookieStore.set('d4a_uid', '', cookieOptions); return NextResponse.json({ message: 'Logged out successfully' }, { status: 200 }); } catch (error) { console.error('Logout error:', error); return NextResponse.json({ message: 'Logout failed' }, { status: 500 }); } }