N
Nuxt4mo ago
xmatthias

Nitro scheduledTask cloudflare

I've got a nuxt app deployed via git integration into cloudflare (it's essentially zero config other than a few environment variables and changing the command from npm run build to pnpm run build). Now i've tried to add a scheduledTask to it - and it works fine in dev mode (it's triggering as configured) - but the deployment part of this is unclear to me, and doesn't seem to work just yet.
nitro: {
experimental: {
tasks: true,
},
scheduledTasks: {
'* * * * *': ['test:scheduler'],
},
},
nitro: {
experimental: {
tasks: true,
},
scheduledTasks: {
'* * * * *': ['test:scheduler'],
},
},
The build-log on cloudflare doesn't mention anything about tasks (other than the file that was built) - and i don't see any trace of the function being executed.
[info] [nitro] Building Nuxt Nitro server (preset: cloudflare-pages)
Nitro seems to use the correct preset - and i don't have a wrangler.toml file present - as the regular nuxt deployment works without it. Am i missing a step here? or is deployment to cloudflare not working out of the box just yet?
1 Reply
saltytostitos
saltytostitos3mo ago
I don't know for sure this is supported yet on Cloudflare Pages without somehow building in Cron Triggers in a worker. Looks like the workers preset is required when deploying. Some context: https://nitro.unjs.io/guide/tasks#platform-support I'd image your best bet for now is to build in a Worker schedule to call Nitro.
Tasks - Nitro
Nitro tasks allow on-off operations in runtime.
Want results from more Discord servers?
Add your server