title: Bypass Cloudflare's captcha with headless chrome using puppeteer on Heroku
body: <p>Im trying to access a site with headless chrome using puppeteer on Heroku. My setup works when I try it locally on my machine, but when trying it mounted on Heroku I get something like this:
  <a href="https://i.stack.imgur.com/odfgz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/odfgz.png" alt="enter image description here" /></a></p>
  <p>I understand that puppeteer comes with javascript enabled by default and for what <a href="https://github.com/puppeteer/puppeteer/issues/4696#issuecomment-511243772" rel="noreferrer">I've read</a> it looks like it has nothing to do with that.</p>
  <p>Im using <a href="https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth" rel="noreferrer">puppeteer-extra-plugin-stealth</a>, <a href="https://github.com/skratchdot/random-useragent" rel="noreferrer">random-useragent</a> and viewport randomization but nothing seems to work.</p>
  <p>Could it be that puppeteer and/or chrome is adding extra stuff when running locally vs on Heroku?</p>
  <p>Here's my setup:</p>
  <pre><code>const puppeteer = require('puppeteer-extra');
  const StealthPlugin = require('puppeteer-extra-plugin-stealth');
  puppeteer.use(StealthPlugin());
  const randomUseragent = require('random-useragent');
  
  const USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36';
  
  
  let browser = await puppeteer.launch(
    { headless: true, executablePath: process.env.CHROME_BIN || null, args: [
      '--enable-features=NetworkService', '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'
    ], ignoreHTTPSErrors: true, dumpio: false}
  );
  let page = await browser.newPage();
  const userAgent = randomUseragent.getRandom();
  const UA = userAgent || USER_AGENT;
  
  //Randomize viewport size
  await page.setViewport({
      width: 1920 + Math.floor(Math.random() * 100),
      height: 3000 + Math.floor(Math.random() * 100),
      deviceScaleFactor: 1,
      hasTouch: false,
      isLandscape: false,
      isMobile: false,
  });
  
  await page.setUserAgent(UA);
  await page.setJavaScriptEnabled(true);
  await page.setDefaultNavigationTimeout(0);
  await page.goto('https://external.site.example', { waitUntil: 'networkidle0' });
  
  ...
  </code></pre>