Jacob S. Jacob S. - 1 year ago 92
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)

Answer Source

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 :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download