I was going to write exactly what you did. I have been seeing a similar behaviour. Perhaps the CF te
I was going to write exactly what you did. I have been seeing a similar behaviour. Perhaps the CF team changed something?




async function fetchWithTurnstile(url: string, options: RequestInit): Promise < Response > {
let response = await fetch(url, options);
if (
response.headers.has('cf-mitigated') &&
response.headers.get('cf-mitigated') === 'challenge'
) {
console.log('Turnstile challenge detected');
await handleTurnstileChallenge();
await new Promise((resolve) => setTimeout(resolve, 1000));
response = await fetch(url, options);
}
return response;
}