gpt4 book ai didi

node.js - Heroku 应用程序抛出错误 : self signed certificate

转载 作者:行者123 更新时间:2023-12-02 19:28:55 25 4
gpt4 key购买 nike

我正在使用免费的heroku 层来部署应用程序。我已经成功创建了应用程序,并且在 Heroku 上构建成功。我推送到 Heroku 并尝试了 heroku local 并且应用程序按预期运行。但是,如果我尝试heroku open,浏览器将打开到heroku“应用程序错误”页面。

我尝试运行 NODE_ENV=Production heroku local 作为故障排除步骤,但这确实导致应用程序崩溃。我明白

Error: self signed certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1492:34)
at TLSSocket.emit (evens.js:315:20)
at TLSSocket._finishInit (_tls_wrap.js:935:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:693:12)

github 仓库在这里:https://github.com/JoeCastr/budget_app

我的package.json:

{
"name": "budget_app_project",
"version": "1.0.0",
"description": "",
"main": "budget.js",
"scripts": {
"start": "npx nodemon budget.js",
"heroku-postbuild": "npm install --production",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-plugin-import": "^2.20.2",
"nodemon": "^2.0.3"
},
"dependencies": {
"bcrypt": "^4.0.1",
"connect-loki": "^1.1.0",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-flash": "0.0.2",
"express-session": "^1.17.1",
"express-validator": "^6.5.0",
"morgan": "^1.10.0",
"pg": "^8.2.1",
"pug": "^2.0.4"
},
"engines": {
"node": "13.12.0",
"npm": "6.14.4"
}
}

最佳答案

问题出在 pg 版本 8.x 上,它破坏了 heroku。连接常数需要是:

const CONNECTION = { 
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
}

关于node.js - Heroku 应用程序抛出错误 : self signed certificate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62098110/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com