May be this is a general issue, which can be available on internet, But what I got is here.
Adding a custom header to HTTP request using angular.js
So I followed the same, and changed the code to
Setting header: //able to get the token from $cookies.token
$http.defaults.headers.common['Authorization'] = $cookies.token;
Please Go through the steps:
Tried with complet url : where api.host = 'http://xx.xx.xx.xx1:9000';(external IP)
return $http({method:'GET', url: api.host+'/aa/734/acd/1860/cd?status=dc',
that time it says error, and the method changed to OPTIONS and the Authorization token has not set.
refer the below image:
And next I changed the api.host = 'localhost' (internal IP) and the code is
return $http({method:'GET', url: '/aa/734/acd/1860/cd?status=dc',
that time the url method is GET, but since the IP is internal it is pointing to my machine. and the Authorization token also set. please refer the below image
When I point to my machine the Authorization token is set, but when I point to external IP it is setting the Method as OPTIONS and the Authorization token is not set.
Any idea from any one.
Thanks in advance.