gpt4 book ai didi

node.js - Strongloop Heroku Postgres 设置 SSL 错误

转载 作者:搜寻专家 更新时间:2023-11-01 00:10:45 24 4
gpt4 key购买 nike

我是 Node.js 世界的新手,并且已经使用 StrongLoop 设置了一个在 Heroku(免费)上运行的应用程序。我设置了 heroku postgresql 插件(免费套餐),并尝试将数据源添加到 StrongLoop 的 arc composer UI。此 UI 更新 server/datasources.json。当我尝试连接到我的数据源时,出现此错误:

no pg_hba.conf entry for host "X.X.X.X", user "myUser", database "mydb", SSL off

我知道问题一定出在在 postgres 上设置 SSL。最接近的 StrongLoop 文档并没有完全讨论这个问题:https://strongloop.com/strongblog/postgresql-node-js-apis-loopback-connector/ ... 因为我使用的是 StrongLoop 而不是直接使用 Node.js,所以 Heroku 的文档也让我缺乏 https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-node-js .我很困惑我需要从这里做什么。

我有相当简单的新闻源类型 JSON 数据,我使用 Handlebars 操作这些数据。因此,如果使用免费层有问题,我愿意接受其他关于我的设置的免费建议。感谢您的帮助。

编辑,datasources.json:

{"db":{"name":"db","connector":"memory"},
"mydb":{
"host":"myhost",
"port":####,
"url":"myamazonawsurl:####/mydbname",
"database":"mydbname",
"password":"mypw",
"name":"mydatasourcename",
"ssl":true,
"user":"myuser",
"connector":"postgresql"}}

更多错误详情:

error: no pg_hba.conf entry for host "X.X.X.X", user "myuser", database "mydb", SSL off at 
Connection.parseE (c:\myroot\node_modules\loopback-connector-postgresql\node_modules\pg\lib\connection.js:539:11) at
Connection.parseMessage (c:\myroot\node_modules\loopback-connector-postgresql\node_modules\pg\lib\connection.js:366:17) at
Socket.<anonymous> (c:\myroot\node_modules\loopback-connector-postgresql\node_modules\pg\lib\connection.js:105:22) at
Socket.emit (events.js:107:17) at readableAddChunk (_stream_readable.js:163:16) at
Socket.Readable.push (_stream_readable.js:126:10)

最佳答案

应该是“?ssl=true”而不是“?sslmode=require”

"devpostgresql": {
"url": "postgres://user:password@ec2-54-228-226-93.eu-west-1.compute.amazonaws.com:5432/dbname?ssl=true",
"name": "devpostgresql",
"connector": "postgresql"
}

关于node.js - Strongloop Heroku Postgres 设置 SSL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31422305/

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