Within my AngularJS application, I am sending a form to a payment gateway. To pass my session token to the backend API, I have included a "Authorization" header field.
However, when attempting to send a request to the payment gateway, an error occurs:
XMLHttpRequest cannot load . Request header field Authorization is not allowed by Access-Control-Allow-Headers.
Coincidentally, the same request works perfectly fine using Postman, returning a 200 status code.
To showcase this issue, I have created a Plunker demo that also receives a 200 status http://plnkr.co/edit/8Ts6s0VDTTUVVC9dbCJC
$http({
method: 'POST',
url: authoriseURL,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
data: nabPaymentData
}).
success(function (response, status, headers) {
alert('Success:' + response + ' status:' + status + ' headers:' + headers);
}).
error(function (err, status, headers) {
alert('Error:' + err + ' status:' + status + ' headers:' + headers);
});
I am curious if there is a way to remove specific header fields for only one POST request?