尝试将应用程序部署到 Heroku 时出现错误代码 = H10

时间:2021-04-17 19:07:29

标签: heroku npm

我将我的后端服务器部署到 heroku 并且构建没有任何问题地完成,但是当我去检查应用程序时,我收到一个应用程序错误。我检查了日志,看看出了什么问题,发现了这一系列错误

H10 error 我查了一下错误,它提到错误有时是由于未绑定到 Heroku 提供的端口引起的。因此,我在后端修复了端口并再次尝试,但仍然出现错误。

我尝试了所有方法,从将主机从 localhost 更改为 0.0.0.0,到修复 Procfile 上的错误。但我仍然收到代码 = H10 错误。有人能告诉我我做错了什么吗?

index.js

const PORT = process.env.PORT || 8080


app.listen(PORT, () => {
  console.log(`Example app listening at port ${PORT}`)
})

package.json

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "axios": "^0.21.1",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "mysql": "^2.18.1",
    "react": "^17.0.2",
    "react-scripts": "^4.0.0"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js",
    "postinstall": "npm run start"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

Procfile

web: node index.js 

0 个答案:

没有答案