This is the code:
app.get('/:id', function (req, res){
usermodel.findOne({ user: req.params.id }, function (err, user1){
console.log(user1);
if (req.session.user != user1.user) {
usermodel.findOne({ user: req.session.user,
follow: user1.id }, function (err, user) {
if (user != null) {
res.render('profile.ejs', {
user: user1,
ses: req.session.user,
foll: true
});
} else {
res.render('profile.ejs', {
user: user1,
ses: req.session.user,
foll: false
});
}
});
} else {
res.render('profile.ejs', {
user: user1,
ses: req.session.user
})
}
});
});
And this is the mongoose schema:
var userschema = new mongoose.Schema({
user: String,
follow: [String],
followers: [String]
});
This code, actually works, but only in local. I've update it to my VPS, and It doesn't work. I try to access to for example http://www.xxxx.com/foo I receive the console.log() output, but the page doesn't load, is loading during 2 minutes, and the browser returns an error.
Basically the code check if the user specified in the URL is the user in the req.session.user, if It isn't, we check if in the _idof the user specified in the URL is in the follow array of the req.session.user, and deppend of the result, we send a value in the variable foll. If it's true, it means that the req.session.user is following the user specified, if it false, it isn't.
In local it works, but I don't know why in my VPS doesn't work! Any solution for this...?
Thank's advance!