Jacob S. Jacob S. - 9 months ago 37
Node.js Question

NodeJS - Passport gives me 404 Error on login

I've just implemented a simple login using Passport.js and passport-local and everything seems to be working, except for the final redirect.

When i log in with bad credentials, I get an error, as it's supposed to happen.

enter image description here

But when I log in with the correct credentials, I get a 404 error for no apparent reason. Sources are too widespread to put here, so you can find them on GitHub: https://github.com/JacobCZ/nodewiki (look into config/express, config/passport, models/user and views/auth)


I noticed a typo on your app/controllers/auth.js

router.post('/login', passport.authenticate('local-login', {
    sucecssRedirect: '/', // <== TYPO (successRedirect)
    failureRedirect: '/login',
    failureFlash: true

That would probably explain it :)