【发布时间】:2020-08-17 12:07:38
【问题描述】:
我的应用是使用 Vue、webpack、Express 和 PostgresSQL 开发的。
我已经将我的应用程序部署到 Heroku,并在 Heroku 上创建了一个 PostgresSQL 数据库。下图是数据库凭证:
然后我将我的应用程序的服务器配置为连接到 Heroku 上的 PostgresSQL 数据库。这是我的代码:
.
.
.
app.use(cors())
app.use(bodyParser.json())
.
.
.
const sequelize = new Sequelize(<My database URI>, {
dialect: "postgres",
protocol: "postgres",
port: 5432,
host: "ec2-18-206-84-251.compute-1.amazonaws.com",
logging: true
});
.
.
.
const port = process.env.PORT || 8081;
sequelize.sync().then(function() {
http.createServer(app).listen(port, function(){
console.log('Express server listening on port ' + port);
});
});
.
.
.
然后我提交并推送到 Heroku,打开我的应用程序,但出现了 Application error。而使用heroku logs --tail,日志显示Unhandled rejection ReferenceError: http is not defined。
我可以看到已经在 Heroku 上的 Postgres DB 上创建了表,如下所示。
请帮助我解决http is not defined 错误。我哪里配置错了?
提前致谢!
【问题讨论】:
标签: node.js postgresql vue.js heroku sequelize.js