Hybrid app: change user HTTP header with AngularJS
I am writing a hybrid app with Cordova and Ionic. My problem is that I want to access the server using an http request and I need to change the device user agent to pass the secret key.
$http({
method: 'GET',
url: 'https://my-server.com/service/',
headers: {
'User-Agent' : 'app_name/2.0 (iOS 8.1) secret=75456789087654',
}
}).success(function(data){
alert(data.content);
}).error(function(){
alert("error");
});
But when I look at the server logs, the user agent hasn't changed:
"GET / service HTTP / 1.1" - "Mozilla / 5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit (KHTML, like Gecko) Chrome Safari" " https://my-server.com/service/ " ...
How do I change the title?
+3
source to share