Using a worker to prime a cache always returns 403 because of firewall

I have a page that requires a long running query to generate that I cache behind cloudflare.

I’d like to use a worker to prime the cache, but am always receiving a 403, forbidden response:

const urls =  ['https://agreatertown.com/vacation-rentals']

async function handleSchedule(scheduledDate) {
  console.log(scheduledDate)
  const res = await Promise.all(urls.map(each=>fetch(each)))
  console.log(res[0].status)
}

I think I’ve properly disabled the firewall in the rules, but perhaps this isn’t the right way to go about it?

Do you see any entries in the Firewall Events Log for your domain in the Cloudflare dashboard? If so, then clicking on it should show you the setting that’s blocking it. It’s quite possible you’ve enabled a bot fight mode that would block such requests.

Indeed, I have Super Bot Fight mode configured to challenge all “Definitely Automated” traffic. Turning that off makes the call succeed.

However, it would be awesome if I could block bots and allow this ping to succeed. Is there a path forward for that?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.