apis-is / apis

Making data readily available to anyone interested
https://apis.is
MIT License
162 stars 64 forks source link

CORS error on weather endpoint #479

Closed saevarom closed 5 years ago

saevarom commented 5 years ago

Describe the issue you are having here.

Steps to reproduce

$.ajax({
  'url': 'http://apis.is/weather/observations/en',
  'type': 'GET',
  'dataType': 'json',
  'data': {'stations': '1,422', 'time': '1h', 'anytime': '0'},
  'success': function(response) {
    console.log(response);
  }
});

The resulting error:

screenshot 2019-01-03 09 35 36
MiniGod commented 5 years ago

Interesting! It looks like this happens because you're using http instead of https. For the last month or so, we've been redirecting http to https with a 301, but forgot to add the CORS headers to the 301 response.

Thanks for pointing this out!

Let me know if https works for you.

saevarom commented 5 years ago

Ah, didn't think of trying https, just copied the example in the docs! HTTPS works, thanks!