# CORS problem when using self hosted tile map server

**URL:** <https://discuss.elastic.co/t/cors-problem-when-using-self-hosted-tile-map-server/289102>\
**Category:** Kibana\
**Tags:** docker, maps\
**Created:** [November 12, 2021, 10:14pm UTC](https://discuss.elastic.co/t/cors-problem-when-using-self-hosted-tile-map-server/289102 "2021-11-12T22:14:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mehrdad22](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mehrdad22](https://discuss.elastic.co/u/mehrdad22)\
**Post date:** [November 12, 2021, 10:14pm UTC](https://discuss.elastic.co/t/cors-problem-when-using-self-hosted-tile-map-server/289102/1 "2021-11-12T22:14:21Z")

</div>

Hi there.  
I'm ran a self hosted OSM tile server with this [repo](https://github.com/Overv/openstreetmap-tile-server). map is working well and functional and accessible with leaflet demo.  
when I use tile map link ( `http://map.company.org:8080/tile/{z}/{x}/{y}.png`) for serving tiles in Kibana map, no tile loaded and browser console print below error:

`Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://map.company.org:8080/tile/65535/65536/17.png. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing)`

I'm digging issues and forums and trying almost all tips and problem is not solved. some of tips:

> - add ALLOW\_CORS=enabled flag when running docker that add "Header set Access-Control-Allow-Origin "\*"" into apache conf.
> - put map server behind reverse proxy and manipulate headers with nginx and dd some headers like this:  
> add\_header 'Access-Control-Allow-Origin' '\*' always;  
> add\_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;  
> add\_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;  
> add\_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
> - change kibana CORS settings; server.cors.enabled.
> - tiles can be downloded in browser without any problem and 'Access-Control-Allow-Origin' '\*' is exist in headers.
> - and etc ... .

I'm so confused and glad to be get help with you, thanks.

ES version: 7.15.1  
Kibana version: 7.15.1

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [November 15, 2021, 3:44pm UTC](https://discuss.elastic.co/t/cors-problem-when-using-self-hosted-tile-map-server/289102/2 "2021-11-15T15:44:07Z")

</div>

You will have to ensure your self hosted OSM tile server has configured [Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) so tile requests from your Kibana domain have permission to access your tile server domain.

> **[Troubleshoot Maps | Kibana Guide \[7.15\] | Elastic](https://www.elastic.co/guide/en/kibana/current/maps-troubleshooting.html#_custom_tiles_are_not_displayed)**

Have you tried the steps out lined at [GitHub - Overv/openstreetmap-tile-server: Docker file for a minimal effort OpenStreetMap tile server](https://github.com/Overv/openstreetmap-tile-server#cross-origin-resource-sharing)? Sounds like passing in `-e ALLOW_CORS=enabled` flag when starting your docker container should turn on the required CORS headers.

---

<div class="post-metadata">

**Author:** ![mehrdad22](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mehrdad22](https://discuss.elastic.co/u/mehrdad22)\
**Post date:** [November 16, 2021, 3:03pm UTC](https://discuss.elastic.co/t/cors-problem-when-using-self-hosted-tile-map-server/289102/3 "2021-11-16T15:03:14Z")

</div>

thanks,  
the problem solved automatically, but I'm guessing its because of prerender processes. after prerendering complete, problem is disappeared and working well.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 14, 2021, 3:03pm UTC](https://discuss.elastic.co/t/cors-problem-when-using-self-hosted-tile-map-server/289102/4 "2021-12-14T15:03:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
