Skip to content
This repository was archived by the owner on Jun 30, 2020. It is now read-only.
This repository was archived by the owner on Jun 30, 2020. It is now read-only.

Error parsing Cloudflare IUAM Javascript challenge. #89

@bakuzan

Description

@bakuzan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions