openplannerteam / routable-tiles

An API and preprocessor to serve routable tiles.
https://openplanner.team/
11 stars 1 forks source link

Nginx configuration errors: cached tile does not contain CORS opt out #22

Closed pietercolpaert closed 5 years ago

pietercolpaert commented 5 years ago

Sometimes, I suspect due to caching, certain tiles do not have a cross origin resource sharing header set correctly

Reproduce

  1. Request https://tiles.openplanner.team/planet/14/8411/5485/ in your browser
  2. Then go to another page such as https://linkedconnections.org, op the console, and execute this: fetch('https://tiles.openplanner.team/planet/14/8411/5480/').then(reponse => { console.log('yes')}); → You will see that it fails due to CORS as it does not contain the access-control-allow-origin: * header.
  3. Try he same line but with a different tile that’s not yet in the server cache: fetch('https://tiles.openplanner.team/planet/14/8409/5410/').then(reponse => { console.log('yes')}); and see that this works.

My console log

Screenshot from 2019-03-25 16-21-16

It may be safe, as this is an open data server, to mark all responses, whether it’s a 500, 400, 300 or 200 with the same header in the NGINX config.

xivk commented 5 years ago

This is fixed now, I enabled CORS only at the NGINX level now for everything. I verified this using the same steps to reproduce as above, feel free to reopen if there is still an issue.