【发布时间】:2021-12-25 08:54:24
【问题描述】:
我正在使用 typeorm 连接到我的 nodejs 应用程序上的 Postgres 数据库。我能够在本地成功连接,但在部署到 heroku 后,根据我的数据库配置出现这些错误。
import { createConnection } from 'typeorm';
...
export const databaseConnection = async (databaseURL:string) => {
try {
await createConnection({
type: "postgres",
url: databaseURL,
entities: [User],
synchronize: true,
ssl: false
});
} catch (error) {
}
};
databaseConnection("<DATABASE_URL_FROM_HEROKU>")
当我这样做时,我收到错误 no pg_hba.conf entry for host , userdatabase SSL off at Parser.parseErrorMessage
当我在连接中使用ssl: true 时,我收到错误:Error: self signed certificate at TLSSocket.onConnectSecure heroku
当我完全删除 ssl 属性时,它仍然没有工作。
我遇到的大多数解决方案都是使用像 here 这样的 sequelize 完成的。但我正在使用 typeorm。请我摆脱这个错误。
【问题讨论】:
标签: node.js postgresql heroku typeorm