From adf84fc29b3368d6a7078cd083504f4c78b835cc Mon Sep 17 00:00:00 2001 From: Aadesh Kheria Date: Thu, 16 Jul 2026 16:00:44 -0700 Subject: [PATCH] Enhance AI proxy response handling by adding X-Generation-Id header - Updated the response headers in the AI proxy integration to include the X-Generation-Id if present in the response from the target URL. - Ensured that response headers are explicitly typed for better clarity and maintainability. --- .../api/latest/integrations/ai-proxy/[[...path]]/route.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/backend/src/app/api/latest/integrations/ai-proxy/[[...path]]/route.ts b/apps/backend/src/app/api/latest/integrations/ai-proxy/[[...path]]/route.ts index 3874ed73d..7677b8784 100644 --- a/apps/backend/src/app/api/latest/integrations/ai-proxy/[[...path]]/route.ts +++ b/apps/backend/src/app/api/latest/integrations/ai-proxy/[[...path]]/route.ts @@ -34,10 +34,14 @@ async function proxyToOpenRouter(req: NextRequest, options: { params: Promise<{ const response = await fetch(targetUrl, { method: req.method, headers: forwardHeaders, body }); - const responseHeaders = { + const responseHeaders: Record = { "Content-Type": response.headers.get("Content-Type") ?? "application/json", "Cache-Control": "no-store", }; + const generationIdHeader = response.headers.get("X-Generation-Id"); + if (generationIdHeader != null) { + responseHeaders["X-Generation-Id"] = generationIdHeader; + } const passthrough = () => new Response(response.body, { status: response.status, headers: responseHeaders });