import { NextRequest } from 'next/server'; const BACKEND_BASE = process.env.NEXT_PUBLIC_BACKEND_URL || 'http://127.0.0.1:8000/api'; export async function GET( req: NextRequest, context: { params: Promise<{ slug: string[] }> } ) { const url = new URL(req.url); const { slug } = await context.params; const path = slug.join('/'); const target = `${BACKEND_BASE}/financials/${path}${url.search}`; const resp = await fetch(target, { headers: { 'Content-Type': 'application/json' } }); // 透传后端响应(支持流式 body) const headers = new Headers(); // 复制关键头,减少代理层缓冲 const contentType = resp.headers.get('content-type') || 'application/json; charset=utf-8'; headers.set('content-type', contentType); const cacheControl = resp.headers.get('cache-control'); if (cacheControl) headers.set('cache-control', cacheControl); const xAccelBuffering = resp.headers.get('x-accel-buffering'); if (xAccelBuffering) headers.set('x-accel-buffering', xAccelBuffering); return new Response(resp.body, { status: resp.status, headers }); }