如何避免 Heroku Postgres 上的 ClientAccess 错误?

How do I avoid ClientAccess error on Heroku Postgres?

技术堆栈:node/js、knex、pg

问题:在我的本地机器上,我的 api 工作正常。迁移到 Heroku,使用 Heroku Postgres 数据库。

目前正在测试:

邮递员请求:GET http://node-express-postgres-neometau.herokuapp.com/api/ipsource (HTTP 和 HTTPS return 同样的错误)

代码执行:

 router.get("/", (req, res) => {
   ipsource.getAllIPSource()
     .then(data => {
         res.status(201).json(data);
       }).catch((err) => {
           res.status(500).json({
              message: "Undefined error on server.",
               error: err
           })
       })
})

错误 returned:

"error": {
        "length": 168,
        "name": "error",
        "severity": "FATAL",
        "code": "28000",
        "file": "auth.c",
        "line": "496",
        "routine": "ClientAuthentication"
    }

我没有更改默认设置;我正在学习的教程(2020 年 4 月)不需要更改任何内容。

之前有一个错误,其中 table 未定义,通过 Heroku CLI 创建了 table 并插入了一个试验行。

我需要在哪里更改哪些设置?

该错误意味着 PostgreSQL 服务器不接受来自使用此数据库和用户名的主机的连接。

您必须向 PostgreSQL 数据目录中的 pg_hba.conf 文件添加适当的条目并重新加载 PostgreSQL。