mirror of
https://github.com/stack-auth/stack.git
synced 2026-07-20 21:29:36 +08:00
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.
This commit is contained in:
parent
299ac703b7
commit
adf84fc29b
@ -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<string, string> = {
|
||||
"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 });
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user