Skip to content

Commit 33acd73

Browse files
committed
fix(dev): remove transfer-encoding header from worker
1 parent 9b276e1 commit 33acd73

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/runner/proxy.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function createHTTPProxy(defaults: ProxyServerOptions = {}): HTTPProxy {
5353
};
5454
}
5555

56-
export function fetchAddress(
56+
export async function fetchAddress(
5757
addr: { port?: number; host?: string; socketPath?: string },
5858
input: string | URL | Request,
5959
inputInit?: RequestInit
@@ -77,16 +77,25 @@ export function fetchAddress(
7777
redirect: "manual",
7878
...init,
7979
};
80+
let res: Response;
8081
if (addr.socketPath) {
8182
url.protocol = "http:";
82-
return fetch(url, {
83+
res = await fetch(url, {
8384
...init,
8485
...fetchSocketOptions(addr.socketPath),
8586
});
87+
} else {
88+
const origin = `http://${addr.host}${addr.port ? `:${addr.port}` : ""}`;
89+
const outURL = new URL(url.pathname + url.search, origin);
90+
res = await fetch(outURL, init);
8691
}
87-
const origin = `http://${addr.host}${addr.port ? `:${addr.port}` : ""}`;
88-
const outURL = new URL(url.pathname + url.search, origin);
89-
return fetch(outURL, init);
92+
const headers = new Headers(res.headers);
93+
headers.delete("transfer-encoding");
94+
return new Response(res.body, {
95+
status: res.status,
96+
statusText: res.statusText,
97+
headers,
98+
});
9099
}
91100

92101
function fetchSocketOptions(socketPath: string) {

0 commit comments

Comments
 (0)