Cannot configure function using vercel.json. Current vercel configuration:
{
"build": {
"env": {
"NEXT_PUBLIC_CONFIG_FILE": "next.config.mjs"
}
},
"crons": [
{
"path": "/api/cron/backup",
"schedule": "0 23 * * *"
}
],
"functions": {
"api/cron/backup": {
"memory": 3009,
"maxDuration": 300
}
}
}
The cron works and executes the function every day. Adding the functions configuration breaks the build with this error:
I know the function exists because it executes every day and is recognized on the deploy’s “functions” tab:
I have also tried slightly different paths including /api/cron/backup and api/cron/backup/*
swarnava
(Swarnava Sengupta)
December 2, 2024, 10:08am
2
Hi, is it a Next.js app? Can you share the folder structure?
1 Like
anshumanb
(Anshuman Bhardwaj)
December 2, 2024, 12:31pm
3
Hi @giovanioliani , could you try function name with the file extension, for example:
"functions": {
"api/cron/backup.js": {
"memory": 3009,
"maxDuration": 300
}
}
To learn more about function configurations, see function
keys .
I hope this helps. If it doesn’t, please include additional information such as framework, folder structure, etc, as Swarnava requested previously.
Hi. Yes, it is a Next.js app. The folder structure has an “app” directory at the root, then /api/cron/backup/route.ts.
Hi, I’ve tried it but it doesn’t match the file unfortunately. The folder structure is shared in my previous comment.
swarnava
(Swarnava Sengupta)
December 2, 2024, 4:50pm
6
"functions": {
"app/api/cron/backup/route.ts": {
"memory": 3008,
"maxDuration": 300
}
or
"functions": {
"app/api/cron/backup/*.ts": {
"memory": 3008,
"maxDuration": 300
}
or
"functions": {
"app/api/cron/backup/*.*": {
"memory": 3008,
"maxDuration": 300
}
Should work I believe
1 Like
Unfortunately none of those work. I get these errors:
anshumanb
(Anshuman Bhardwaj)
December 4, 2024, 11:52am
9
Hi @giovanioliani , can you use the format that @swarnava suggested above because it should include “app” in the path which the image above doesn’t show.
I just tried replicating your project:
And it worked fine for me. Here’s the output:
1 Like
Thank you for pointing that out @anshumanb . I had tried so many times I became numb to the details. Using “app/api/cron/backup/route.ts” worked for me. You can close this if you want to.
2 Likes
system
(system)
Closed
December 16, 2024, 9:58pm
11
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.