vendredi 5 août 2016

Ember ignoring header params on ajax call

I have the following API call to github:

return new Ember.RSVP.Promise(function(resolve, reject){
      $.ajax({
        type: 'POST',
        url: 'http://ift.tt/1j0ZcDZ',
        crossDomain: true,
        xhrFields: {withCredentials: true},
        data: { 'code': code, 'client_id': 'xxx'  },
        dataType: 'json',
        headers: {
          'Access-Control-Allow-Origin': 'http://127.0.0.1:4200/'
        },
        success: Ember.run.bind(null, resolve),
        error: Ember.run.bind(null, reject)
      });
    }).then(function(user){

although the header is properly set, I get this response from github:

XMLHttpRequest cannot load http://ift.tt/1j0ZcDZ. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:4200' is therefore not allowed access. The response had HTTP status code 404.

Seems like the headers are being ignore.
I've tried with beforeSend and configure the header and didn't worked as well




Aucun commentaire:

Enregistrer un commentaire