'how do start cron in nextjs after server restart , we not using custom server

how do start cron in the next js after server restart? NOTE: we not using a custom server.

we are using the next API routes.

how do trigger the function after the npm run start command. or else npm run dev.



Solution 1:[1]

in your package.json you can create your custom "dev" function or modify which scripts will be run. Example:

"scripts": {
    "web:dev": "env-cmd -f environments/.env.development node server.js",
    "build": "next build ",
    "sitemap": "next-sitemap --config next-sitemap.config.js",
    "start": "next start"
  },

So, you can add the name of your file (need to create your nodejs file with functions needed) an it will be triggered

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 illia chill