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

export async function POST() {
  try {
    await signOut();
    // This line won't be reached because signOut() redirects
    return NextResponse.json({ success: true });
  } catch (err) {
    console.error("[auth/sign-out] Error:", err);
    // Even if signOut throws, redirect to login
    return NextResponse.redirect(new URL("/login", process.env.NEXT_PUBLIC_SITE_URL ?? "http://localhost:4000"));
  }
}