gpt4 book ai didi

mongodb - Heroku + Node.js + MongoHQ + expressjs

转载 作者:可可西里 更新时间:2023-11-01 09:58:27 26 4
gpt4 key购买 nike

我正在尝试将 Heroku 与 Mongo 一起用于 Express.js 项目。努力连接到mongohq。日志输出:

connstring 是:mongodb://heroku:XXXXXXXXXXXXXXXXXXXXXXXX@staff.mongohq.com:10073/app676842主机是:staff.mongohq.com

app.configure(function() {
app.set('connstring', process.env.MONGOHQ_URL
|| ('mongodb://' + app.set('m_host') + '/' + app.set('m_database')));
console.log('connstring is: ' + app.set('connstring'));
var uri = parseUri(app.set('connstring'));
console.log('host is: ' + uri.host);
app.use(express.bodyParser());
app.use(express.cookieParser());

// use connect-mongo as session middleware
app.use(express.session({
secret: 'topsecret',
store: new store({ db: app.set('m_database'), host: uri.host })
}));
app.use(express.methodOverride());
app.use(app.router);

// use express logger
app.use(express.logger({ format: '\x1b[1m:method\x1b[0m \x1b[33m:url\x1b[0m :response-time ms' }));
app.use(express.static(__dirname + '/public'));
});

最佳答案

你设置密码了吗?

尝试将您的连接字符串更改为:

mongodb://heroku:YourPassword@staff.mongohq.com:10073/app676842

假设您的用户名设置为“heroku”

关于mongodb - Heroku + Node.js + MongoHQ + expressjs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6966255/

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