LoginScreenshot
I’m developing a MEAN application with my team. The backend is set up, the front end is setup, the routes and everything yet for some reason it won’t load, it gives these two errors
GET http://localhost:3500/auth/login 404 (Not Found)
ERROR HttpErrorResponse {headers: HttpHeaders, status: 404, statusText: 'Not Found', url: 'http://localhost:3500/auth/login', ok: false, …}error: "<h1>Not Found</h1>rn<h2>404</h2>rn<pre>NotFoundError: Not Foundn at G:\OneIncident\server\config\app.js:102:7n at Layer.handle [as handle_request] (G:\OneIncident\node_modules\express\lib\router\layer.js:95:5)n at trim_prefix (G:\OneIncident\node_modules\express\lib\router\index.js:317:13)n at G:\OneIncident\node_modules\express\lib\router\index.js:284:7n at Function.process_params (G:\OneIncident\node_modules\express\lib\router\index.js:335:12)n at next (G:\OneIncident\node_modules\express\lib\router\index.js:275:10)n at G:\OneIncident\node_modules\express\lib\router\index.js:635:15n at next (G:\OneIncident\node_modules\express\lib\router\index.js:260:14)n at Function.handle (G:\OneIncident\node_modules\express\lib\router\index.js:174:3)n at router (G:\OneIncident\node_modules\express\lib\router\index.js:47:12)</pre>rn"headers: HttpHeaderslazyInit: () => {…}lazyUpdate: nullnormalizedNames: Map(0) {size: 0}[[Prototype]]: Objectmessage: "Http failure response for http://localhost:3500/auth/login: 404 Not Found"name: "HttpErrorResponse"ok: falsestatus: 404statusText: "Not Found"url: "http://localhost:3500/auth/login"[[Prototype]]: HttpResponseBaseconstructor: class HttpErrorResponse[[Prototype]]: Object
The screenshots show a better view of it
For some reason, in my controller > index.js, its using the !user block but even so, it cannot find the redirect /auth/login, it doesn’t do the req.loginLoginIndexController
`
My process login controller
module.exports.processLoginPage = (req,res,next)=> {
passport.authenticate('local',
(err,user,info)=> {
//server error?
if(err){
return next(err);
}
//is there a user login error?
if(!user)
{
req.flash('loginMessage','Authentication Error');
return res.redirect('/auth/login');
}
req.login(user, (err)=> {
//server error?
if (err) {
return next(err);
}
const payload = {
id: user._id,
displayName: user.displayName,
username: user.username,
email: user.email
}
const authToken = jwt.sign(payload, DB.Secret, {
expiresIn: 604800 // 1 week
});
// TODO - Getting ready to convert to API
return res.json({sucess: true, msg: 'User Logged in Successfully!', user:{
id: user._id,
displayName: user.displayName,
username: user.username,
email: user.email
}, token: authToken});
// return res.redirect('/incidentlist');
});
})(req,res,next);
}
`
`
My post
router.post('/login',indexController.processLoginPage);
`
I tried changing the routing and it just bounces between saying /login not found and /auth/login not foundLoginIndexRouter