app.get('/logout', function (req, res){
req.url='/';
console.log('req.url is ' + req.url);
req.session.state = null;
res.redirect('/login');
});
upon redirect, the 'url' remains the same. I want it to change it too. Which i tried to do using req.url. But it does not reflect on the url-bar. How do you change that?
Note:- I'm using Angularjs Routing so the res.redirect
is not automatically updating the url.
Edit:- Angular Code:-
$http({method: 'GET', url: '/logout'}).
success(function(data, status, headers, config) {
console.log('happened');
}).
error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
By default res.redirect
will send a response with a 302 status code and a Location header with the URL you call the function with. So in your case something like:
HTTP/1.1 302
Location: http://example.com/login/
You will need to handle this on the AngularJS side to change the URL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With