Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Workers AI local mode fetcher not returning headers to client worker #5138

Merged
merged 6 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: ensure Workers-AI local mode fetcher returns headers to client worker
8 changes: 6 additions & 2 deletions packages/wrangler/src/ai/fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Response } from "miniflare";
import { Headers, Response } from "miniflare";
import { performApiFetch } from "../cfetch/internal";
import { getAccountId } from "../user";
import type { Request } from "miniflare";
Expand All @@ -16,5 +16,9 @@
duplex: "half",
});

return new Response(res.body, { status: res.status });
const respHeaders = new Headers(res.headers);
respHeaders.delete("Host");
respHeaders.delete("Content-Length");

Check warning on line 21 in packages/wrangler/src/ai/fetcher.ts

View check run for this annotation

Codecov / codecov/patch

packages/wrangler/src/ai/fetcher.ts#L19-L21

Added lines #L19 - L21 were not covered by tests

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

Check warning on line 23 in packages/wrangler/src/ai/fetcher.ts

View check run for this annotation

Codecov / codecov/patch

packages/wrangler/src/ai/fetcher.ts#L23

Added line #L23 was not covered by tests
}
Loading