Hi, I am new to node and I am creating a simple MEAN stack application to reduce the code that I am sending front files such as
app.use(express.static(path.join(__dirname, 'public')));
I also create a simple middleware for easy authentication
requireLogin = function (req, res, next) {
if (!req.user) {
console.log('redirecting :)');
res.redirect('/');
} else {
next();
}
};
app.use('/rooms',requireLogin);
I am trying to use this middleware on routes made in angular. but this does not work when I navigate my angular application (it works when I directly put the URL in the address bar). I also deleted / # /, which angular added.
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
I use ui-router for routing.
source
share