node.js - Heroku 崩溃错误:heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico"
问题描述
我正在尝试在 heroku 上启动我的 nodejs 应用程序。但是每次它启动它都会崩溃并出现以下错误。人们不断提到我必须进行一些端口修复,但我不明白在哪里以及如何进行?有人可以帮我调试这个崩溃问题。如果我在本地运行它,npm start
它工作正常。
这是我的仓库:https ://github.com/Gorgutzz/portfolio-site
2020-08-25T02:29:52.559666+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-25T02:30:03.658131+00:00 heroku[web.1]: Starting process with command `npm start`
2020-08-25T02:30:06.506095+00:00 app[web.1]:
2020-08-25T02:30:06.506170+00:00 app[web.1]: > portfolio-site@0.1.0 start /app
2020-08-25T02:30:06.506176+00:00 app[web.1]: > react-scripts start
2020-08-25T02:30:06.506181+00:00 app[web.1]:
2020-08-25T02:30:09.243945+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.17.138.30/
2020-08-25T02:30:09.244281+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-08-25T02:30:09.244350+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-08-25T02:30:09.244420+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-08-25T02:30:09.244654+00:00 app[web.1]: Starting the development server...
2020-08-25T02:30:09.244655+00:00 app[web.1]:
2020-08-25T02:30:09.336466+00:00 heroku[web.1]: Process exited with status 0
2020-08-25T02:30:09.382429+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-25T02:30:17.664264+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=leo-port123.herokuapp.com request_id=d96f2dd2-7ebf-4123-a30a-2a499c5e826f fwd="24.102.208.138" dyno= connect= service
= status=503 bytes= protocol=http
2020-08-25T02:30:18.664310+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=leo-port123.herokuapp.com request_id=f5a14315-78c3-41b9-b90c-ae748f7f4800 fwd="24.102.208.138" dyno= conne
ct= service= status=503 bytes= protocol=http
解决方案
Heroku 在每次 dyno 启动时随机分配的端口上运行。你有三个选择:
- 将 Heroku Buildpack 用于零配置 React 应用程序:https ://elements.heroku.com/buildpacks/mars/create-react-app-buildpack
- 使用 Express https://medium.com/better-programming/how-to-deploy-your-react-app-to-heroku-aedc28b218ae
- 使用其他手动设置端口的方法。这可能会有所帮助:在 Heroku 上设置 node.js 服务器的端口
推荐阅读
- function - 从不推荐使用的 cudnn 函数转换为工作函数
- javascript - 这个字符串替换功能是如何工作的?
- java - 是否可以在两个 WAR 之间共享 Spring Web 端点?
- jquery - 引导模式仅在我的机器上不显示
- javascript - sinon 不会取代依赖
- delphi - Delphi 10.4 将默认 VirtualTree 的默认属性存储在 .dfm 文件中
- css - 如何使用 currentColor 在 SCSS 中更改 SVG 颜色
- asp.net - 如何在我的域站点核心中添加 www?网
- windows - 向 docker 中的 Windows 容器提供 Windows 凭据
- javascript - 复选框未响应 onChange - React