I'm using ember data with different URL as i'm moving from ember-rails, to external ember application, so API url is http://localhost:5000 and ember application is http://localhost:9000.
Now the problem is I need to include x-appid and x-app-secret, but whenever add xhr.setRequestHeader() for any of them, the GET request becomes OPTIONS request.
This code was working fine when i was using ember-rails on the same domain, is this the problem or is there something else missing?
ajax: function(url, type, hash) {
if (this.headers !== undefined) {
var headers = this.headers;
if (hash) {
hash.beforeSend = function (xhr) {
// Works fine
xhr.setRequestHeader('Accept', 'application/vnd.vendor+json;version=1');
// Changes Request from GET to OPTIONS
xhr.setRequestHeader('x-vendor-appid', '12412412');
xhr.setRequestHeader('x-vendor-secret', 'aslkdfjaskldfjasd');
};
}
}
return this._super(url, type, hash);
}