gpt4 book ai didi

javascript - SequelizeConnectionError : self signed certificate

转载 作者:行者123 更新时间:2023-12-01 15:19:56 29 4
gpt4 key购买 nike

我正在尝试连接到我在 Heroku 中设置的 PostgreSQL 数据库。

const { Sequelize, DataTypes, Model } = require("sequelize");

// DB Configuration
const sequelize = new Sequelize({
database: "[wont'd show db]",
username: "[won't show username]",
password: "[won't show password]",
host: "ec2-54-221-195-148.compute-1.amazonaws.com",
port: 5432,
dialect: "postgres",
dialectOptions: {
ssl: true,
},
});


这就是我得到的输出:

SequelizeConnectionError: self signed certificate

最佳答案

这是由于 node-postgres 中的(意外)重大更改。版本 8(见 this GitHub issue)。
解决办法是通过rejectUnauthorized: falsesequelize dialectOptions 内的连接参数> ssl ,如 described here by GitHub user jsanta :

const sequelize = new Sequelize({
database: "xxxxx",
username: "xxxxx",
password: "xxxxx",
host: "xxxxx",
port: 5432,
dialect: "postgres",
dialectOptions: {
ssl: {
require: true,
rejectUnauthorized: false // <<<<<<< YOU NEED THIS
}
},
});

关于javascript - SequelizeConnectionError : self signed certificate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58965011/

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