node redirect not working on angular node redirect not working on angular express express

node redirect not working on angular


You should do redirecting on angular, but not on node.js application. For example,

requireLogin = function (req, res, next) {  if (!req.user) {      console.log('User does not exist.');      return false;      //   } else {      next();  }};app.use('/rooms', requireLogin);

Then, /rooms won't be able to access unless there is user logged-in.

Backend routes (express ones): Those are the routes that an end user won't have to know about or even use them (your angular app will use them to communicate with the backend to work with its data but an end user wouldn't put them directly on the browser)).

Frontend routes (angular ones): Are the routes that maps to different pages of your application and because of that, end users can use them to access some parts of your application directly.

Read Express.js or angular for handling routes in a MEAN application? for more details.