Having an issue with Angular.js (and possibly express) routing. I was able to resolve the routing for regular subpages, but now I need to include some publicly accessible pages like signup
, password-lost/reset
, and so on. However, whenever I try to access http://127.0.0.1/signup
, it automatically redirects me to http://127.0.0.1/login
.
Here is my Angular routing in app.js
:
$locationProvider.html5Mode(true);
$routeProvider.when('/login', {templateUrl: 'views/login.html', controller: 'LoginCtrl'})
.when('/password-reset/:reset', { templateUrl: 'views/password-lost/password-reset.html', controller: 'LoginCtrl' })
.when('/signup', { templateUrl: 'views/signup.html', controller: 'SignupCtrl' })
.otherwise({ redirectTo: '/' });
And this is my server routing in server.js
:
app.get('*', function (req, res) {
// res.sendfile(__dirname + '/public/index.html'); I also tried this option, but encountered the same issue
res.redirect('/#' + req.originalUrl);
});
The value of req.originalUrl
contains the correct view, such as /signup
.
Since my views are located inside /public/views
, I attempted:
res.redirect('/#/views/' + req.originalUrl);
But it did not solve the problem.
Can anyone provide insight into why my route changes from /signup
to /login
unexpectedly?