versatiles-org/versatiles-documentation

CORS issue

kevinvenclovas opened this issue · 1 comments

Hi, I published my versatiles server on Google Cloud like described here: https://github.com/versatiles-org/versatiles-documentation/blob/main/guides/deploy_in_google_cloud.md .
Except for the load balancer point, there may be a Google Cloud issue currently. Every time I try to create a load balancer, I get an error message.

I used the frontend version and it works pretty well. For my next step, I wanted to style my map using: https://maplibre.org/maputnik After adding the tile URL as a data source, nothing happened. In the console, I can see MapLibre throwing a CORS error when requesting the tiles from https://.../tiles/map/{z}{x}{y}.

I searched on Google, but with no results. Maybe someone can help me here. How can I enable CORS on my Google Cloud Run?

image

Hi, CORS can be set by sending a HTTP header "Access-Control-Allow-Origin" with a value of "*" to allow all origins or a specific domain. By default CORS only allows AJAX requests from the same domain. So if you are using Maputnik from a different domain, CORS will prevent any tiles from being served.
Unfortunately we haven't implemented CORS in the server yet, so you need to add the HTTP header to the "Backend Service" in the "Load Balancer".
Hopefully we can add CORS to the server implementations in the next few weeks.