question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CORS for map tiles?

See original GitHub issue

We currently enable CORS only for metadata_api, not for tile_api or spec_api:

https://github.com/DHI-GRAS/terracotta/blob/3c9feff9910382da1c827f11d8a84e7f08a44970/terracotta/server/flask_api.py#L21

However, we need CORS also for map tiles when using Mapbox GL as a client, because it fetches the data inside the web client, rather than just letting the browser load the images directly, like Leaflet does it.

What is the rationale behind not enabling CORS for all endpoints? And if we were to change that, should we just enable CORS everywhere or make it a configurable option (CORS=false or so)?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

1reaction
mrpgraaecommented, Feb 4, 2020

Like @dionhaefner I also think the first option is preferable, but the second one is fine too.

1reaction
dionhaefnercommented, Jan 29, 2020

Config sounds good. With CORS enabled globally, anyone can hijack the Terracotta server and request tiles in the backend of their own application, which might get costly. Of course you can still hijack the server in the frontend without CORS, so the only real protection is proper authentication.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can leafletjs use map tiles from a non-CORS server and ...
The map tiles come from another internal server named maps.local . Leaflet finds the tiles perfectly given the appropriate tile URL http:// maps...
Read more >
CORS errors | Help - Mapbox docs
Learn how to address CORS errors. ... CORS (cross origin request sharing) errors can be identified by checking for error ... Blank or...
Read more >
CORS problem when using self hosted tile map server - Kibana
Hi there. I'm ran a self hosted OSM tile server with this repo. map is working well and functional and accessible with leaflet...
Read more >
CORS error when requesting coverage vector tiles
Requesting a tile with curl works fine but when I try to add the tiles as a Leaflet layer, I get a CORS...
Read more >
Trying to use Tile overlays - Need CORS help
In creating Tile Overlay in a GEW project I received the dreaded: "Access to XMLHttpRequest at 'https://br1.nic.edu/giga/89093/89093_files/7/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found