import { NextResponse } from "next/server";
import { headers } from "next/headers";

// Pays par défaut pour le sélecteur de téléphone, déduit de l'IP via l'en-tête
// Vercel `x-vercel-ip-country` (code ISO-2). En local / hors Vercel, renvoie null
// et le client retombe sur FR.
export const dynamic = "force-dynamic";

export async function GET() {
  const h = await headers();
  const country = h.get("x-vercel-ip-country");
  return NextResponse.json({ country: country || null });
}
