This is the process flow:
On the front end, the user logs in by providing username and password.
The server will respond a token to the user if the credentials are correct.
Now the user should be redirected to the homepage (PROBLEM HERE). I have set the token in the header by this code: $http.defaults.headers.common['X-Auth-Token'] = token;
Also, when I do a http.get method, I am getting an "OK" response
$http({ method: 'GET', url: '/home/', headers: { 'X-Auth-Token': token } }).then(function successCallback(response) { console.log(response.statusText); }
Now, the issue is that when I use $window.location.href = "/home", the server responds "unauthorized token" because the server always expects a token in the header with each request. In the command window.location.href, I cannot set the header.
What is an alternative to redirect the user to the homepage. Assume the server always checks the header for the access token.
Thanks in advance!!!
ngRouteorangular-ui-router)?