import { NextResponse } from 'next/server';

export const dynamic = 'force-dynamic';

const BACKEND_URL = process.env.BACKEND_URL || 'http://localhost:3000';

/**
 * Desk-showcase proxy (item 6) — real alt-line ladder + same-team correlation
 * from the snapshot. Any failure → { available:false } so the visuals hide.
 */
export async function GET() {
  try {
    const upstream = await fetch(`${BACKEND_URL}/api/desk-showcase`, {
      method: 'GET', headers: { Accept: 'application/json' }, cache: 'no-store',
    });
    const data = await upstream.json().catch(() => ({ available: false }));
    return NextResponse.json(data, { status: 200, headers: { 'Cache-Control': 'public, s-maxage=300, stale-while-revalidate=60' } });
  } catch {
    return NextResponse.json({ available: false }, { status: 200 });
  }
}
