import { NextRequest, NextResponse } from "next/server";
import { backendUrl, isOpsAuthed, opsHeaders } from "@/lib/ops-auth";

export async function GET(req: NextRequest) {
  if (!isOpsAuthed(req)) {
    return NextResponse.json({ message: "No autorizado." }, { status: 401 });
  }
  const res = await fetch(backendUrl("/hooks/ot-ops/visits"), {
    headers: opsHeaders(),
    cache: "no-store",
  });
  const data = await res.json().catch(() => ({}));
  return NextResponse.json(data, { status: res.status });
}
