import { NextResponse } from "next/server"
import { SESSION_COOKIE } from "@/lib/auth"

export async function POST() {
  try {
    const response = NextResponse.json({ success: true }, { status: 200 })
    response.cookies.set(SESSION_COOKIE, "", {
      httpOnly: true,
      secure: process.env.NODE_ENV === "production",
      sameSite: "strict",
      path: "/",
      maxAge: 0,
    })
    return response
  } catch (error) {
    console.error("Logout error:", error)
    return NextResponse.json(
      { error: "Logout failed." },
      { status: 500 }
    )
  }
}
