ajnisbet / opentopodata

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

Enabling CORS on api.opentopodata.org #53

Closed takkaria closed 2 years ago

takkaria commented 2 years ago

Hiya, thanks so much for this resource, it's great. Would you consider turning on CORS headers for the public API? I was poking around and I can see there's support in the code for this already (otherwise I'd submit a PR to add it). If not, no worries, and thanks again!

ajnisbet commented 2 years ago

Hi, thanks for raising this!

I have some general info here about CORS:

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:

  • Host ajnisbet/opentopodata on your own server with CORS enabled
  • Proxy requests from api.opentopodata.org through your own server, adding the appropriate CORS header
  • If you're working on academic research or a small non-commercial project, send me an email and I can add you to a whitelist on the public api.
  • Use the GPXZ elevation api

That said, I see you have a non-profit listed on your github profile and I'd love to help out with that, please send an email to andrew@opentopodata.org with any CORS domains you need added, and let me know if there's anything else I can do!