Sunday, 16 April 2017

mLab doesn't work on Heroku

I've added mLab to my Heroku app, I also use mongoose. I tried use connection string from localhost, and it was working(almost). In my server file I use:

var db = mongoose.connection;
if (process.env.MONGODB_URI) {
 mongoose.connect('mongodb://heroku_fb82r7lw:bbgj8uliam1psdda88fleu55li@ds161580.mlab.com:61580/heroku_fb82r7lw');

    // mongoose.connect(process.env.MONGODB_URI);
} else {
 mongoose.connect('mongodb://heroku_fb82r7lw:bbgj8uliam1psdda88fleu55li@ds161580.mlab.com:61580/heroku_fb82r7lw');

    // mongoose.connect('mongodb://localhost/fitMe')
}

If I open the app from localhost, it saves things to the db, and can get it back, although not everything, but on heroku it doesn't work at all. I use react with server. I think that something wrong with the routs.. so here is the link to server file : https://github.com/HelenaVolskaia/Motivation/blob/master/server/app.js



via Elena Volskaia

No comments:

Post a Comment