fix(fetcher): better detect inline Cloudflare Turnstile

This commit is contained in:
WebStreamr 2025-08-11 11:40:42 +00:00
parent 24d2cff3f7
commit 0efdfa4a6f
No known key found for this signature in database

View file

@ -112,7 +112,9 @@ export class Fetcher {
};
private async handleHttpCacheItem(ctx: Context, httpCacheItem: HttpCacheItem, url: URL, init?: CustomRequestInit): Promise<HttpCacheItem> {
if (httpCacheItem.status && httpCacheItem.status >= 200 && httpCacheItem.status <= 399) {
const triggeredCloudflareTurnstile = httpCacheItem.body.includes('cf-turnstile');
if (httpCacheItem.status && httpCacheItem.status >= 200 && httpCacheItem.status <= 399 && !triggeredCloudflareTurnstile) {
return httpCacheItem;
}
@ -122,7 +124,7 @@ export class Fetcher {
const responseHeaders = httpCacheItem.policy.responseHeaders();
if (httpCacheItem.policy.responseHeaders()['cf-mitigated'] === 'challenge') {
if (httpCacheItem.policy.responseHeaders()['cf-mitigated'] === 'challenge' || triggeredCloudflareTurnstile) {
const noFlareSolverr = init?.noFlareSolverr ?? false;
const flareSolverrEndpoint = envGet('FLARESOLVERR_ENDPOINT');
if (noFlareSolverr || !flareSolverrEndpoint) {