CORS policy blocks access

Hello,
I tried to follow this example: https://developer.tomtom.com/maps-sdk-web-js/tutorials/display-vector-map and I had lots of errors like this:

Access to XMLHttpRequest at https ://api.tomtom.com/map/1/copyrights/caption.json?key=key from origin ‘http ://www.mysite.it’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.

Thhanks

1 Like

Put your API key without any brackets.

And please don’t publish your key on the portal.

1 Like

This depends on Browser used. I believe Firefox does this, while Chrome should be ok. @dsanandreas you can try with another browser to unblock yourselves.

The Browser sends HTTP OPTIONS request first, before sending HTTP GET for actual data, and the OPTIONS request checks on server side whether access is allowed from Cross Origin Domains.

Server Side support for OPTIONS might be required to allow CORS.