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
D Trombett
D Trombett6mo ago
Workers have a built in Cron feature btw
PneuTueur
PneuTueurOP6mo ago
Yes, I know. It is the feature I was talking about
D Trombett
D Trombett6mo ago
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 it
PneuTueur
PneuTueurOP6mo ago
I 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 worker
D Trombett
D Trombett6mo ago
I'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

Did you find this page helpful?