puppeteer icon indicating copy to clipboard operation
puppeteer copied to clipboard

[Bug]: Browser challenged

Open Mecanik opened this issue 6 months ago • 0 comments

Minimal, reproducible example

import puppeteer from "@cloudflare/puppeteer";

export default {
  async fetch(request, env) {
    const { searchParams } = new URL(request.url);
    let url = searchParams.get("url");
    let img;
    if (url) {
      url = new URL(url).toString(); // normalize
      img = await env.BROWSER_KV_DEMO.get(url, { type: "arrayBuffer" });
      if (img === null) {
        const browser = await puppeteer.launch(env.MYBROWSER);
        const page = await browser.newPage();
        await page.goto(url);
        img = await page.screenshot();
        await env.BROWSER_KV_DEMO.put(url, img, {
          expirationTtl: 60 * 60 * 24,
        });
        await browser.close();
      }
      return new Response(img, {
        headers: {
          "content-type": "image/jpeg",
        },
      });
    } else {
      return new Response("Please add an ?url=https://example.com/ parameter");
    }
  },
};

Error string

no error

Bug behavior

  • [ ] Flaky
  • [ ] PDF

Background

I've been trying to test out the example provided in the docs, however if you try and capture a screenshot of a website that is on Cloudflare the "checking your browser" page is shown.

Expectation

Since this is a fork of the original puppeteer and it's running inside the Cloudflare network, I was expecting that some lenience is provided so that the browser is not "challenged" - this makes it completely useless - for me at least. The only other solution would be to use puppeteer-extra-plugin-stealth which literally creates a conflict of interest (breaking your own security?).

Reality

Almost all my websites are on Cloudflare, so any of the sites tested are challenged. Lowering the security of the specific site makes no sense. I cannot see the probable usage of this on the Cloudflare Workers platform.

Puppeteer configuration file (if used)

No response

Puppeteer version

0.0.13

Node version

20.10.0

Package manager

npm

Package manager version

10.2.4

Operating system

Linux

Mecanik avatar Aug 25 '24 18:08 Mecanik