简体   繁体   中英

PM2 run nodejs sveltekit app with options

I have an app that i bult with npm run build, with sveltekit, everything works fine, but i have to specify the ORIGIN like it says here https://github.com/sveltejs/kit/tree/master/packages/adapter-node , to make it run otherwise i run in to this problem "Cross-site POST form submissions are forbidden". I run it like this and it works fine ORIGIN=http://myorigin node out/index.js. Now i need to register it to PM2 but i find nothing to run it with the origin parameter. I have also tried to set the ORIGIN keu in the.env file, and installing dotenv, but i still need to run this command: node -r dotenv/config build, with options, and i cant make it start from PM2. Is there a way to do this? Thanks

i found this and it worked https://pm2.keymetrics.io/docs/usage/application-declaration/

module.exports = {
  apps : [{
    name   : "app",
    script : "ORIGIN=http://myorigin node out/index.js"
  }]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM