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(),
});
2 Replies
Dan Claroni
Dan ClaroniOP6mo ago
Thank you so much! This worked. Do you have any tips on using puppeteer-extra and stealth?
Want results from more Discord servers?
Add your server