/**
 * Proxy: Admin → Backend /api/compliance/agent/admin/benchmark
 * (P107 — Branchen-Benchmark-Cockpit)
 */
import { NextRequest, NextResponse } from 'next/server'

const BACKEND_URL = process.env.BACKEND_API_URL || 'http://backend-compliance:8002'

export async function GET(request: NextRequest) {
  const qs = request.nextUrl.searchParams.toString()
  try {
    const r = await fetch(
      `${BACKEND_URL}/api/compliance/agent/admin/benchmark?${qs}`,
      { signal: AbortSignal.timeout(20000) },
    )
    const body = await r.text()
    return new NextResponse(body, {
      status: r.status,
      headers: { 'Content-Type': r.headers.get('content-type') || 'application/json' },
    })
  } catch (e: any) {
    return NextResponse.json(
      { error: 'Benchmark-API nicht erreichbar', detail: String(e) },
      { status: 503 },
    )
  }
}
