CORS problem when using self hosted tile map server

Hi there.
I'm ran a self hosted OSM tile server with this repo. 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

You will have to ensure your self hosted OSM tile server has configured Cross-Origin Resource Sharing (CORS) so tile requests from your Kibana domain have permission to access your tile server domain.

Have you tried the steps out lined at GitHub - Overv/openstreetmap-tile-server: Docker file for a minimal effort OpenStreetMap tile server? Sounds like passing in -e ALLOW_CORS=enabled flag when starting your docker container should turn on the required CORS headers.

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

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