cloudflare icon indicating copy to clipboard operation
cloudflare copied to clipboard

Error parsing Cloudflare IUAM Javascript challenge.

Open bakuzan opened this issue 5 years ago • 2 comments

Trying to use the package on the following json endpoint: https://animepahe.com/api?m=search&l=8&q={searchString}

My code looks like the following:

const got = require('got');
const fetch = require('node-fetch');
const { catchCloudflare } = require('@ctrl/cloudflare');
const { CookieJar } = require('tough-cookie');

async function cloudflareBypass(url, reqOpts) {
  const cookieJar = new CookieJar();
  const options = {
    url,
    cookieJar,
    retry: 0,
    ...reqOpts
  };

  let response = null;

  try {
    response = await got(options);
  } catch (error) {
    response = await catchCloudflare(error, options);
  }

  return response;
}

module.exports = async function myFetch(opts, reqOpts) {
  const bypassCloudflare = opts.cloudflare || false;

  if (!bypassCloudflare) {
    return await fetch(opts.url, { method: 'GET', ...reqOpts });
  } else {
    return await cloudflareBypass(opts.url, reqOpts);
  }
};

It correctly hits the catchCloudflare section of the code but errors with the following error appears:

Error parsing Cloudflare IUAM Javascript challenge. Cloudflare may have changed their technique, or there may be a bug in the script. Check for recent updates then file a bug report at https://github.com/typectrl/cloudflare/issues

bakuzan avatar Jun 25 '20 08:06 bakuzan

yeah cloudflares recent changes make passing the challenge much harder without a browser. I would try something like https://github.com/ngosang/FlareSolverr

scttcper avatar Jun 25 '20 19:06 scttcper

@scttcper That is a shame. Thanks for the info though.

bakuzan avatar Jun 26 '20 07:06 bakuzan