Error when calling geocode and directions

Greetings everyone,

I’m using geocode and directions api to generate many routes from addresses(i’m sending about 200 queries each time) and sometimes it doesn’t work properly and show me this error:
Access to XMLHttpRequest at ‘https://api.openrouteservice.org/geocode/search?api_key=key&text=16%20RUE%20DECAUVILLE%20,CORBEIL-ESSONNES,91100&boundary.country=FR’ from origin ‘http://localhost:8080’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

What does it mean and how can i resolve it ?

Thanks in advance.

Hi @maghraoui_dhia

please don’t post your API key as other people will be able to use it (also is a hint in the topic placeholder which you should read before posting)
Regarding your problem, please provide an exact full query and response with headers included.

Normally the response should include the access-control-allow-origin: * header:

HTTP/2 200 OK
server: nginx/1.19.2
date: Tue, 18 May 2021 12:28:46 GMT
content-type: application/json; charset=utf-8
content-length: 1788
access-control-allow-headers: X-Requested-With,content-type
access-control-allow-methods: GET, OPTIONS
access-control-allow-origin: *
cache-control: public
charset: utf8
etag: W/"6fc-xlJ4X1xAceStfBefks5/GXZupj8"
x-powered-by: pelias
x-ratelimit-limit: 1000
x-ratelimit-remaining: 742
x-ratelimit-reset: 1621344357
x-robots-tag: none
access-control-allow-methods: OPTIONS,GET,POST
access-control-allow-headers: Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Authorization, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers
access-control-expose-headers: x-ratelimit-remaining, x-ratelimit-reset, x-ratelimit-limit
X-Firefox-Spdy: h2

My guess is, that you run into the minutely request limit of 100 requests (Plans | Openrouteservice which you should adhere to) and the error response is not including the header.

Best regards

1 Like