I am calling a web service with a jQuery Ajax request and I need to pass an authorization header. So I have something like the below...
$.ajax
({
type: "GET",
url: "https://emmawatson.com/askForaDate",
dataType: 'json',
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Basic YXBpdHVybnRvQGFwaS5jb206QXBpMzIxJDEyMw');
},
success: handleData
});
When I look at the request headers in the outgoing request, I only see this..
Access-Control-Request-Headers:authorization
Access-Control-Request-Method:GET
I was expecting to see something like this..
authorization:Basic YXBpdHVybnRvQGFwaS5jb206QXBpMzIxJDEyMw
So it looks like the authorization request header is not being sent.
I also tried the other approaches suggested in this post and this one.
Could anyone tell me what I am missing? How do I get the actual header value to show up in the request headers?