I have an api which requires few headers to passed to get the response.Below is the working postman
Now Iam doing an http call to consume this and below is the
The MDN page for XMLHttpRequest.setRequestHeader() states:
For your custom fields, you may encounter "not allowed by Access-Control-Allow-Headers in preflight response" exception when you send request to cross domain. In this situation, you need set "Access-Control-Allow-Headers" in your response header at server side.
In your case, the X-Rundeck-Auth-Token
header is such a custom header, and therefore this header must be listed in the Access-Control-Allow-Headers
response header from the server, otherwise you'll get an error as above and the request will fail.
Accept
, Accept-Language
, Content-Type
, Content-Length
are whitelisted headers that can be set without specifying them in the Access-Control-Allow-Headers
header; there's also a list of request headers that can never be set, even if they are listed.