Comment régler ce soucis et avoir des crons qui ne me renvoie plus une erreur 404 ?

My Vercel cron jobs are returning a ‘404 Not Found’ error. I am currently developing my Next.js 14 application, and it’s deployed on Vercel. I can see the cron jobs in the ‘Settings’ > ‘Cron Jobs’ section of my Vercel dashboard.

Here is my vercel.json file:

{
  "crons": [{
    "path": "/api/cron/alert-before-experience",
    "schedule": "10,30,50 * * * *"
  }, {
    "path": "/api/cron/alert-no-disponibility",
    "schedule": "* 2 * * *"
  }, {
    "path": "/api/cron/transfer-from-platform-to-connected-accounts",
    "schedule": "0 * * * *"
  }]
}

During the build process, my routes are correctly generated in the application, and they match the routes defined in the vercel.json file.

Here are the build logs:

[07:16:49.847] Route (app) Size First Load JS
[07:16:49.847] ┌ ○ /_not-found 882 B 85.7 kB
...
[07:16:49.850] ├ λ /api/cron/alert-before-experience 0 B 0 B
[07:16:49.850] ├ λ /api/cron/alert-no-disponibility 0 B 0 B
[07:16:49.850] ├ λ /api/cron/transfer-from-plateform-to-connected-accounts 0 B 0 B
...
[07:17:17.473] Deployment completed

When I try to run the cron jobs by clicking the “Run” button in the Vercel dashboard, I consistently receive a ‘404 Not Found’ error, no matter which cron job I try to execute. The same error occurs when I attempt to run them from the monitoring section.

However, the cron routes work correctly in two scenarios:

  1. When I manually visit the URL (“xxx-rho.vercel.app”)
  2. When I run the route from the monitoring section by replacing the deployment URL (which is the default when cron jobs are called): “xxx-n4j9x2s83-yannis-dev.vercel.app” → “xxx-rho.vercel.app”

So, the routes are functional with the host “xxx-rho.vercel.app,” but for some reason, Vercel is using the host of the last deployment by default, such as “xxx-n4j9x2s83-yannis-dev.vercel.app.”

How can I resolve this issue and ensure that the cron jobs do not return a ‘404 Not Found’ error?