Skip to content

Commit

Permalink
Fix Workers AI local mode fetcher not returning headers to client worker
Browse files Browse the repository at this point in the history
  • Loading branch information
G4brym committed Mar 1, 2024
1 parent 9d1d11c commit d5c2e39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/yellow-phones-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Fix Workers-AI local mode fetcher not returning headers to client worker
9 changes: 8 additions & 1 deletion packages/wrangler/src/ai/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,12 @@ export async function AIFetcher(request: Request) {
duplex: "half",
});

return new Response(res.body, { status: res.status });
const respHeaders: Record<string, string> = {};
for (const [name, value] of res.headers) {
respHeaders[name] = value;
}
respHeaders.headers.delete("Host");
respHeaders.headers.delete("Content-Length");

return new Response(res.body, { status: res.status, headers: respHeaders });
}

0 comments on commit d5c2e39

Please sign in to comment.