res.redirect() is not responding any thing

380
March 21, 2017, at 6:55 PM

I am using nodejs,Express,Angular and Mongoose in my application.I have used passport local authentication. the authentication is working fine but after that res.redirect() to any html page is not working.

exports.postLogin = (req, res, next) => {
req.assert('Email', 'Email is not valid').isEmail();
req.assert('Password', 'Password cannot be blank').notEmpty();
req.sanitize('Email').normalizeEmail({ remove_dots: false });
const errors = req.validationErrors();
if (errors) {
    //req.flash('errors', errors);
    console.log(errors);
    return res.redirect('/index.html');
    //res.render('index.html');
}


passport.authenticate('local', (err, user, info) => {
    if (err) { return next(err); }
    if (!user) {
        //req.flash('errors', info);
       console.log(info);
         return res.redirect('/');
    }
    req.logIn(user, (err) => {
        if (err) { return next(err); }
        console.log("Success");
        //req.flash('success', { msg: 'Success! You are logged in.' });
        res.render('ManageCarts.html');
      //res.redirect('ManageCarts.html');
    });
})(req, res, next);
};

I have tried both res.redirect() and res.render() but two them are not working.

If i removed .html it is showing in console as 404 status because everything I am using html but when I refer correct page is not showing anything in the console as well as browser is also static.

I couldn't understand why the problem exist.

Does anybody know what I am missing here?!?!

Thanks!

Rent Charter Buses Company
READ ALSO
angular2 - issue by using router

angular2 - issue by using router

first of all I am a complete beginner at this kind of programming with nodejs, angular2 and typescriptBasically i start reading on https://angular

375
any suggestion to shorten the installation time of npm in teamcity

any suggestion to shorten the installation time of npm in teamcity

Trying to use teamcity to build and deploy ionic programbut every time teamcity need to install all npm modules

326
How can I take variable from ejs to app.js in Node.js?

How can I take variable from ejs to app.js in Node.js?

I'm pretty newbie in nodejs and trying to pass JSON data from ejs to app

458
null values in redis throws a deprecated warning

null values in redis throws a deprecated warning

Adding null values in redis hashes throws a deprecated warning Description of the warning :

563