import { NextResponse } from "next/server";

const BACKUP_URL = process.env.BACKUP_SERVICE_URL || "http://127.0.0.1:8083";

export async function POST(request: Request) {
  try {
    const body = await request.json().catch(() => ({}));
    const res = await fetch(`${BACKUP_URL}/backup/verify`, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(body),
    });
    const data = await res.json();
    return NextResponse.json(data, { status: res.status });
  } catch {
    return NextResponse.json({ error: "Backup service unavailable" }, { status: 503 });
  }
}
