如何使用Node.js绑定Heroku中的端口
Heroku像这样犯错误
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60
seconds of launch
我认为端口没有问题,但是许多文档说超时是端口问题
我的代码
const port = process.env.port || 8080;
app.listen(port, () => {
console.log(process.env.port);
console.log(`SERVER is running at ${port}`);
})
回答如下:要在Heroku上使用环境变量,您需要在仪表板中进行设置。打开https://dashboard.heroku/apps/YOUR_APP_NAME/settings,然后单击REVEAL CONFIG VARS
按钮。之后,您应该可以设置环境变量。另外,如果使用.env
文件,则需要将其删除。