vendredi 30 juin 2017

Vue-Request not sending Authorization Header

I'm using VueJS with vue-request for http requests. I'm trying to subscribe an user to a Mailchimp list but Mailchimp uses BasicAuth, so I'm doing as such:

   scope.$http.post('http://ift.tt/2sZS3AI',
{...mydata...}, {headers: {Authorization: 'Basic myencodedAPIkey'}})

But I get an error from the API: 401 Unauthorized - Your request did not include an API key.

So I check the Network log on Chrome and the Authorization is on my headers like this: Access-Control-Request-Headers: authorization but it should be like Authorization: myencodedAPIkey

On the Console the error appears as:

XMLHttpRequest cannot load http://ift.tt/2sZS3AI. 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:8000' is therefore not allowed access. The response had HTTP status code 401.

When I use Postman it works just fine as the header is correctly sent.




Aucun commentaire:

Enregistrer un commentaire