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


source to share





All Articles