import { NextRequest, NextResponse } from 'next/server'; const API_BASE_URL = process.env.API_BASE_URL || 'http://localhost:8001'; /** * Proxy route for ReviewIQ trends endpoint. * GET /api/pipelines/reviewiq/trends */ export async function GET(request: NextRequest) { try { // Forward query parameters const searchParams = request.nextUrl.searchParams; const queryString = searchParams.toString(); const url = `${API_BASE_URL}/api/pipelines/reviewiq/trends${queryString ? `?${queryString}` : ''}`; const response = await fetch(url, { method: 'GET', headers: { 'Content-Type': 'application/json', }, cache: 'no-store', }); if (!response.ok) { const errorData = await response.json().catch(() => ({})); return NextResponse.json( { detail: errorData.detail || `Backend error: ${response.status}` }, { status: response.status } ); } const data = await response.json(); return NextResponse.json(data); } catch (error) { console.error('ReviewIQ trends proxy error:', error); return NextResponse.json( { detail: 'Failed to fetch trends data' }, { status: 500 } ); } }