且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Heroku cedar 堆栈上的 Node.js 端口问题

更新时间:2023-02-24 14:31:00

你能展示你调用 listen 的整个代码部分吗?您应该检查流程环境变量 PORT,而不仅仅是将其硬编码为 3000.来自他们的 docs一个>:

Can you show the entire section of code where you call listen? You should be checking for the process environment variable PORT, not just hardcoding it to 3000. From their docs:

var port = process.env.PORT || 3000;
app.listen(port, function() {