ajnisbet / opentopodata

Open alternative to the Google Elevation API!
https://www.opentopodata.org
MIT License
314 stars 68 forks source link

API blocking fetch requests #9

Closed carsonsaldanha closed 4 years ago

carsonsaldanha commented 4 years ago

I'm trying to implement the API by fetching the JSON via JavaScript's fetch API or jQuery, but I'm getting an error that access to fetch the API has been "blocked by CORS policy," which usually indicates that the end site is blocking fetch requests. Screenshot 2020-08-09 at 3 47 27 PM

Am I doing something wrong or is this as intended?

ajnisbet commented 4 years ago

Hey, thanks for raising this!

The open software in this repo has full support for browser-based fetch requests and CORS policy. However, the free instance I'm hosting at api.opentopodata.org is configured to block cross-origin requests. These requests effectively bypass the per-IP rate limit, and I want to make sure the server has enough capacity for everyone!

So there are a couple of options to get this working: