Send a request to my worker's endpoint from a cron trigger event?
So I set up a cron trigger that should send a request every 15 minutes to one of my worker's routes using
fetch
with await
keyword. However, it seems that the request is never sent (the operation expected is not performed) while it succeeds when I use the Javascript console of any browser.6 Replies
Workers have a built in Cron feature btw
Cloudflare Docs
Cron Triggers | Cloudflare Workers docs
Enable your Worker to be executed on a schedule.
Yes, I know. It is the feature I was talking about
You mentioned that you're using
fetch
. The Workers Cron Trigger executes the scheduled
handler, not the fetch
one so make sure you've configured itI configured a scheduled handler for my cron triggers which is executed (I can see it with
wrangler tail
). However, I meant that I was using the native fetch
API to send a request to the workerI'm not sure why would you do such a thing (you can extract it to a function and run the same function in the scheduled and fetch handlers, which is way more efficient) but anyway with wrangler tail you should get the error that is coming out from your worker