【发布时间】:2021-04-14 13:16:32
【问题描述】:
您好,我最近在使用heroku,但由于价格更好,我决定换成数字海洋。
我部署了数字海洋,确保将环境设置为生产环境。
一切似乎都很好 但是当我打开实时应用时,它只是一个空白屏幕,而不是我的网站。
有没有人可以为我指明正确的方向?
if(process.env.NODE_ENV === 'production'){
console.log('Production Enviroment')
app.use(express.static(path.join(__dirname, 'build')))
}
app.get('*', (req,res) =>{
res.sendFile(path.join(__dirname+'/build/index.html'));
});
const port = process.env.NODE_ENV === 'production' ? process.env.PORT : 4000;
app.listen(port, () => {
console.log('Server listening on port ' + port);
});
【问题讨论】:
标签: node.js deployment digital-ocean production