import { NextRequest, NextResponse } from 'next/server' const BACKEND_URL = process.env.BACKEND_URL || 'http://localhost:8002' /** * Proxy: GET /api/sdk/v1/screening → Backend GET /api/v1/screening * Lists screenings for the current tenant. */ export async function GET(request: NextRequest) { try { const { searchParams } = new URL(request.url) const queryString = searchParams.toString() const url = `${BACKEND_URL}/api/v1/screening${queryString ? `?${queryString}` : ''}` const response = await fetch(url, { method: 'GET', headers: { 'Content-Type': 'application/json', ...(request.headers.get('X-Tenant-ID') && { 'X-Tenant-ID': request.headers.get('X-Tenant-ID') as string, }), }, }) if (!response.ok) { const errorText = await response.text() return NextResponse.json( { error: 'Backend error', details: errorText }, { status: response.status } ) } const data = await response.json() return NextResponse.json(data) } catch (error) { console.error('Failed to fetch screenings:', error) return NextResponse.json( { error: 'Failed to connect to backend' }, { status: 503 } ) } }