【发布时间】:2020-01-13 20:26:47
【问题描述】:
我有一个简单的 MERN 应用程序在本地开发并运行。但是,在部署到 Heroku 后,我有“无法访问站点”。
这是我的 Heroku 日志:
2019-09-12T00:33:00.665358+00:00 heroku[web.1]: Starting process with command `npm start`
2019-09-12T00:33:03.909328+00:00 app[web.1]:
2019-09-12T00:33:03.909347+00:00 app[web.1]: > myStreet@1.0.0 start /app
2019-09-12T00:33:03.909349+00:00 app[web.1]: > node server.js
2019-09-12T00:33:03.909351+00:00 app[web.1]:
2019-09-12T00:33:05.050233+00:00 heroku[web.1]: State changed from starting to up
2019-09-12T00:33:04.994283+00:00 app[web.1]: LISTENING ON PORT 3001
2019-09-12T00:33:05.082318+00:00 app[web.1]: (node:23) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2019-09-12T00:33:05.229315+00:00 app[web.1]: connected to the database
2019-09-12T00:33:12.960721+00:00 app[web.1]: GET / 404 4.000 ms - 139
2019-09-12T00:33:12.960048+00:00 heroku[router]: at=info method=GET path="/" host=dry-hamlet-33823.herokuapp.com request_id=d8a5cd47-50fa-428a-92d0-97ccba40db05 fwd="65.95.137.53" dyno=web.1 connect=2ms service=14ms status=404 bytes=415 protocol=https
出了什么问题,我该如何解决?我使用 process.env.PORT 来设置端口。
============= 感谢大家的帮助,我通过观看https://www.youtube.com/watch?v=e1LaekAnVIMo解决了这个问题
【问题讨论】:
-
你能发布你的服务器JS页面吗?或者,如果你有一个带有代码的 git repo。
标签: node.js reactjs heroku deployment