dfr*_*ese 10 javascript ssl heroku knex.js dotenv
我不断收到此错误:
Error: self signed certificate
在终端中运行此命令时:
knex migrate:latest --env production
Run Code Online (Sandbox Code Playgroud)
我的 knexfile.js
require('dotenv').config();
module.exports = {
development: {
client: "pg",
connection: {
host: "localhost",
database: "my-movies"
}
},
production: {
client: "pg",
connection: process.env.DATABASE_URL
}
};
Run Code Online (Sandbox Code Playgroud)
我的 .env 文件:
DATABASE_URL=<my_database_url>?ssl=true
Run Code Online (Sandbox Code Playgroud)
Heroku 应用信息:
Addons: heroku-postgresql:hobby-dev
Auto Cert Mgmt: false
Dynos:
Git URL: https://git.heroku.com/path-name.git
Owner: xxxxxxxxx@xxxx.com
Region: us
Repo Size: 0 B
Slug Size: 0 B
Stack: heroku-18
Web URL: https://my-appname.herokuapp.com/
Run Code Online (Sandbox Code Playgroud)
我试过在 ssl: true 的 knexfile 的生产中放置一个键值对,但我得到了同样的错误。我过去已经这样做过很多次了,从来没有遇到过这个问题。想知道 Heroku 是否改变了任何东西,但在搜索他们的文档时我找不到任何东西。
pir*_*x22 16
以下配置knexfile.js对我有用。
...
production: {
client: 'postgresql',
connection: {
connectionString: process.env.DATABASE_URL,
ssl: { rejectUnauthorized: false }
}
}
...
Run Code Online (Sandbox Code Playgroud)
这DATABASE_URL是你通过跑步得到的heroku config --yourAppName
这是由于 pg@^8 (2020/02/25) cf 中的重大更改所致。这个heroku帮助论坛。
您可以获取完整的 pg@^8 公告,但以下是相关段落:
现在我们将使用 tls.connect 的默认 ssl 选项,其中包括启用拒绝Unauthorized。这意味着如果您使用自签名证书,您的连接尝试可能会失败。
而且 Heroku 似乎在某处使用自签名证书。
可能的解决方案:
ssl: { rejectUnauthorized: false }(请参阅上面链接的公告)| 归档时间: |
|
| 查看次数: |
3859 次 |
| 最近记录: |