我目前正在尝试将我的javascript+webpack应用程序部署到Heroku上。
应用程序here的Github链接。
它在本地运行良好,但我无法将其部署到Heroku上。我收到一条错误消息,如:App boot timeout
。请看下面的截图:
截图1:
截图2:
有谁知道我该怎么解决这个问题吗?
ps:我尝试了Netlify,设法让应用程序显示,但API调用不起作用,因为我的API URL以http而不是https开头,但没有办法为这个项目选择的API不在https上:-(这就是为什么我试图让这个在Heroku上工作。
发布于 2021-06-10 20:03:03
这是因为您的express代码绑定到端口8081,而heroku喜欢在部署express应用程序时传入自己的端口。这就是为什么您的错误消息显示为Web process failed to bind to $PORT within 60 seconds of launch
。要解决这个问题,您需要将port作为变量传递并绑定到它。
server.js
const app = require("./index.js");
app.set('port', process.env.PORT || 8081);
app.listen(app.get('port'), function () {
console.log(`running on localhost: `, server.address().port);
});
最小代码示例here。
https://stackoverflow.com/questions/67927552
复制相似问题