import { NextResponse } from 'next/server';
import { cookies } from 'next/headers';

export async function POST() {
  const cookieStore = await cookies();
  
  // Hapus cookie jumpa_token dengan maxAge 0 dan domain yang sesuai
  cookieStore.set('jumpa_token', '', {
    httpOnly: true, // BARU-S2 FIX: Must match login's httpOnly:true to properly delete cookie
    secure: true,
    sameSite: 'lax',
    path: '/',
    domain: process.env.NEXT_PUBLIC_COOKIE_DOMAIN || undefined, // Mengikuti domain tempat aplikasi berjalan
    maxAge: 0 // Expire immediately
  });

  return NextResponse.json({ success: true, message: 'Logged out successfully' });
}
