const BACKEND_BASE = process.env.BACKEND_INTERNAL_URL || process.env.NEXT_PUBLIC_BACKEND_URL;

export async function GET(
  _req: Request,
  context: { params: Promise<{ symbol: string }> }
) {
  if (!BACKEND_BASE) {
    return new Response('BACKEND_INTERNAL_URL/NEXT_PUBLIC_BACKEND_URL 未配置', { status: 500 });
  }
  const { symbol } = await context.params;
  const target = `${BACKEND_BASE}/companies/${encodeURIComponent(symbol)}/profile`;
  const resp = await fetch(target, { headers: { 'Content-Type': 'application/json' } });
  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 });
}


