I am working on a phonegap app which uses Backbone JS. During ajax calls the header contains:
"Origin":"file://"
Which is not supported by the server. I tried to set Origin header as null but in chrome it is not allowed.
Backbone.ajax = function() {
arguments[0].headers = {
'Accept': "application/json",
'Origin': "null"
};
return Backbone.$.ajax.apply(Backbone.$, arguments);
};
Which throws error:
Refused to set unsafe header "Origin"
Only work around I can think of to solve this issue is to use the cordovaHttp plugin. But I am unable to figure out how to override Backbone.ajax to use cordovHTTP.
Link to the cordova plugin: https://github.com/silkimen/cordova-plugin-advanced-http
Although this is related to CORS, my question is specific to Overriding Backbone ajax method using the cordovaHttpPlugin