I am trying to request an API using fetch in javascript. I did it in the simplest way, just declaring the method I am using and the header with the api key and auth.:
fetch(url, {
method: "GET",
headers: {
"Authorization": "Bearer 0123456789",
"x-api-key": "9876543210"
}
})
The request sent by the browser changes the original fetch request:
- The method sent is "OPTIONS" instead of "GET".
- The header parameters (api key and auth) are included on "Access-Control-Request-Header" instead to be included directly on the header.
see how it is sent by the browser
How can I avoid the browser to change the method and keep the api key and auth. directly on the request header?
Thanks a lot