When I am going to my external server, I would like to pass some header variables like X-CLIENT-NAME . Is it possible?
For a cordova solution, you'll need to either compile your own cordova lib or use a plugin such as cordova-HTTP, specifically setHeader
, from the README:
cordovaHTTP.setHeader("Header", "Value", function() {
console.log('success!');
}, function() {
console.log('error :(');
});
With Angular, you can also use the $httpProvider.defaults.headers
object in order to set your headers for all requests, just POST, or just PUT. See the Setting HTTP Header section here: https://docs.angularjs.org/api/ng/service/$http
With Supersonic, you can set extra headers directly for INCOMING responses:
network:
extraResponseHeaders:
"Access-Control-Allow-Origin": "*"
"Access-Control-Allow-Headers": "Content-Type, X-Requested-With"
This allows you to add extra response headers to responses coming in, so e.g. even if your server doesn't give CORS headers, you can force them. There's no similar native-level extraRequestHeaders
setting ATM.