// app/api/auth/debug/route.ts
import { NextResponse } from "next/server";
import { cookies } from "next/headers";
import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs";

export async function GET() {
  try {
    const supabase = createRouteHandlerClient({ cookies });
    const { data: { session }, error } = await supabase.auth.getSession();
    if (error) return new NextResponse(error.message, { status: 400 });
    return NextResponse.json({
      hasCookies: !!cookies().getAll().length,
      session,
      user: session?.user ?? null,
    });
  } catch (e: any) {
    return new NextResponse(e?.message || "Internal Server Error", { status: 500 });
  }
}
