/**
 * Proxy: GET /api/sdk/v1/agent/migration/<checkId>/banner-preview
 *   -> backend GET /api/compliance/agent/migration/<checkId>/banner-preview
 */
import { NextRequest, NextResponse } from 'next/server'

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

export async function GET(
  request: NextRequest,
  { params }: { params: Promise<{ checkId: string }> },
) {
  const qs = request.nextUrl.searchParams.toString()
  const url = `${BACKEND_URL}/api/compliance/agent/migration/${(await params).checkId}/banner-preview${qs ? `?${qs}` : ''}`
  try {
    const resp = await fetch(url, { signal: AbortSignal.timeout(15000) })
    const data = await resp.json()
    return NextResponse.json(data, { status: resp.status })
  } catch {
    return NextResponse.json(
      { error: 'Banner-Preview fehlgeschlagen' },
      { status: 503 },
    )
  }
}
