Configuring Node.js Connection String for Mongo Labs Database on Heroku

南笙酒味 提交于 2019-12-01 13:43:01

I answered this in the comments on my tutorial, but I'll answer it here too: I think it's likely that you need to use the environment variable referenced in the Heroku ducomentation you linked: process.env.MONGOLAB_URI ... my guess is that Heroku doesn't want you putting your username/password directly into the code (and with good reason, since that's not particularly secure). Give it a shot with:

var db = mongo.db(process.env.MONGOLAB_URI, {native_parser:true});

and see how that works out.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!