HTTP returning blobs are all length 0.
I've got a proxy that was working, but now seems to not work.
The server logs are printing out the correct blob size, but my browser is saying content-length = 0
The server logs are printing out the correct blob size, but my browser is saying content-length = 0
const proxy = httpAction(async ({}, request) => {
// treat everything after the real domain as the url to proxy
console.log("PROXY", request.url);
let urlToCheck = new URL(request.url).pathname.slice(7);
if (urlToCheck.startsWith("//")) {
urlToCheck = "https:" + urlToCheck;
}
const url = new URL(urlToCheck);
console.log("PROXY", url);
const resp = await fetch(url);
console.log("PROXY", resp);
const blob = await resp.blob();
console.log("PROXY", blob);
// return resp;
// const body = await resp.text();
return new Response(blob, {
headers: {
"content-type": resp.headers.get("content-type") || "image/png",
"content-length": resp.headers.get("content-length") || "0",
},
status: 200,
});
});const proxy = httpAction(async ({}, request) => {
// treat everything after the real domain as the url to proxy
console.log("PROXY", request.url);
let urlToCheck = new URL(request.url).pathname.slice(7);
if (urlToCheck.startsWith("//")) {
urlToCheck = "https:" + urlToCheck;
}
const url = new URL(urlToCheck);
console.log("PROXY", url);
const resp = await fetch(url);
console.log("PROXY", resp);
const blob = await resp.blob();
console.log("PROXY", blob);
// return resp;
// const body = await resp.text();
return new Response(blob, {
headers: {
"content-type": resp.headers.get("content-type") || "image/png",
"content-length": resp.headers.get("content-length") || "0",
},
status: 200,
});
});