502 Bad Gateway with nginx | Google App Engine | Node JS

后端 未结 8 2414
时光取名叫无心
时光取名叫无心 2020-12-15 15:50

I am hosting the web app on Google Cloud Platform with App Engine and I am using ExpressJS and MongoDB, which is hosted on mLab.

Everything worked well until 1/1/201

8条回答
  •  轮回少年
    2020-12-15 16:14

    Create a server and then check with a ternary condition if current environment is production or not, assign port '80' if current environment is development else assign process.env.NODE.ENV.

    const app = require('express')();
            const server = require('http').Server(app);
            const port = process.env.NODE_ENV === 'production' ? process.env.PORT :'80';
            server.listen(port, ()=> {
              console.log('listening on port number  *:' + server.address().port);
             });
    

提交回复
热议问题