cloudscraper-ts
Node.JS library to bypass some of Cloudflare's anti-ddos page. All credit goes to the original author here.
About CloudScraper
There are some anti-bot pages such as NovelUpdates that can be bypassed via the normal CloudScraper package. I simply rewrote it and added TypeScript types to it.
Usage
This is pretty scuffed, so I suggest you take a look at the original GitHub page for more documentation. Essentially, all that the function does is the following:
const request = require("./dist/index").default;
const body = {
action: "nd_ajaxsearchmain",
strType: "desktop",
strOne: "Mushoku Tensei",
strSearchType: "series"
}
request({
uri: "https://www.novelupdates.com/wp-admin/admin-ajax.php",
method: "POST",
formData: body
}, {
challengesToSolve: 3
}).then(res => {
console.log(res.body);
});"Just a moment..." (Orchestrate) challenge
Some sites show Cloudflare’s "Just a moment..." page (orchestrate / challenge-platform). That challenge runs in the browser and cannot be solved with plain HTTP. You can solve it in three ways (in order of precedence when using the default solver):
-
FlareSolverr (optional) – If the env variable
FLARESOLVERR_URLis set (e.g.http://localhost:8191/v1), the default solver will call your FlareSolverr instance first. No Node browser dependency; useful when you already run FlareSolverr (e.g. in Docker). Copy.env.sampleto.envand setFLARESOLVERR_URLfor local testing. -
Puppeteer or Playwright (optional) – If
FLARESOLVERR_URLis not set or the request fails, the default solver tries Puppeteer first, then Playwright. Install at most one:npm install puppeteerornpm install playwright. Both are optional; if you use FlareSolverr you don’t need either. If neither is installed and FlareSolverr isn’t used, the solver will throw a clear message when the orchestrate challenge is hit.
Default solver (recommended) – uses the order above:
const request = require("cloudscraper-ts").default;
const { createDefaultOrchestrateSolver } = require("cloudscraper-ts");
request(
{ uri: "https://example.com/protected" },
{
solveOrchestrateChallenge: createDefaultOrchestrateSolver({
headless: true,
timeout: 45000,
}),
}
)
.then((res) => console.log(res.body))
.catch((err) => console.error(err));Other options:
- FlareSolverr only: pass
createFlareSolverrOrchestrateSolver(process.env.FLARESOLVERR_URL). - Pick a browser: use
createPuppeteerOrchestrateSolver()orcreatePlaywrightOrchestrateSolver()to force one. - Custom solver: pass a
solveOrchestrateChallenge(context)function. It receives{ url, response, body, cookieJar }. Openurlin a browser (or call an API), then set the cookies oncookieJar. The library will retry with the new cookies. - No solver: don’t pass a solver; the library throws
OrchestrateChallengeErrorwhen the "Just a moment..." page is hit.