Google CORS timezone API request

I am trying to query the Google Timezone API from an AngularJS app.

But when I make my request, I got this error in the preflight request:

XMLHttpRequest cannot load https://maps.googleapis.com/maps/api/timezone/json?location=48.8709,2.3561&timestamp=14912286400&key=MY_KEY. Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.

      

Here is my google API config: enter image description here

I tried to disable pre-request by setting the header with Content-Type: 'text/plain'

, but there is always a pre-flight request.

Do you think the above error is caused by a preflight request or do you think I should be looking in a different direction?

Thank you in advance

EDIT : I know how to enable CORS on my server, this is not the point. I want to access Google APIs from my AngularJS app without creating a WS on my server (if possible). If I have no choice, I'll do it, but in this case, I know how to do it.

ANSWER . Thanks to @Sebas I solved the API issue window.fetch()

. This doesn't work on IE, but there is a big polyfill here: https://github.com/github/fetch . I don't know if this is the best option for solving my problem, but it works.

+3
javascript angularjs cors preflight


source to share


No one has answered this question yet

Check out similar questions:

3915
Why does Google add while (1); into your JSON responses?
2268
Why does my JavaScript code get the error "No Access-Control-Allow-Origin header" on the requested resource ", but Postman doesn't?
1744
Cancel Ajax requests with jQuery
327
The requested resource does not contain the "Access-Control-Allow-Origin" header - when trying to get data from the REST API
317
Preflight request response fails access control check
308
CORS. What is the motivation behind implementing pre-flight requests?
252
AngularJS makes HTTP OPTIONS request for cross origin resource
226
No "Access-Control-Allow-Origin" - Node / Apache Port Problem
197
Request header field. Access-Control-Allow-Headers are not allowed on their own in preflight response
140
How to enable CORS in AngularJs



All Articles
Loading...
X
Show
Funny
Dev
Pics