gpt4 book ai didi

javascript - SequelizeConnectionError : self signed certificate

转载 作者:行者123 更新时间:2023-12-03 22:31:34 26 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: false 传递给 sequelize 连接参数,如 described here by GitHub user jsanta :

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: {
require: true,
rejectUnauthorized: false // <<<<<<< YOU NEED THIS
}
},
});

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

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