Dan Claroni
Dan Claroni
Explore posts from servers
CDCloudflare Developers
Created by Dan Claroni on 5/28/2024 in #workers-help
how to convert puppeteer.HTTPResponse to cloudflare Response
I am trying to convert a puppeteer.HTTPResponse into a cloudflare response. Before I moved to cloudflare workers, I was able to do this with the following code. However, currently with cloudflare I get the following error: ReferenceError: Buffer is not defined Code that previously worked:
const response = await page.goto(request.url);
if (!response) {
throw new Error(`Request to ${request.url} failed.`);
}

return new Response(await response.text(), {
status: response.status(),
});
const response = await page.goto(request.url);
if (!response) {
throw new Error(`Request to ${request.url} failed.`);
}

return new Response(await response.text(), {
status: response.status(),
});
3 replies