I've looked at a number of similar questions on SO but, so far, none of the solutions have worked. What I found is that when I test it in IE, cURL or Postman, it works fine. However in Chrome 56, I get:
Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.
Examining the headers returned by the preflight request made by chrome, it looks like the correct headers are being returned. So why isn't Chrome following it up with the POST?
Found a related question: AJAX function w/ Mailgun, getting "ERROR Request header field Authorization is not allowed by Access-Control-Allow-Headers". Trying to do pretty much the same thing. The big question is how to I prevent Chrome from sending a preflight request?
Code:
$.ajax({
type: "POST",
url: url,
headers: {
"Authorization": "Basic " + btoa(user + ":" + pass)
},
data: {
from: "someEmail@mycompany.com",
to: "robot@mycompany.com",
subject: "New Message",
text: textbody
},
success: function (){
alert('Thanks for your comment!');
}
});