# CORS problem in Kibana Map

**URL:** https://discuss.elastic.co/t/cors-problem-in-kibana-map/193710
**Category:** Kibana
**Created:** [August 5, 2019, 3:47am UTC](https://discuss.elastic.co/t/cors-problem-in-kibana-map/193710 "2019-08-05T03:47:47Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Daniel6](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@Daniel6](https://discuss.elastic.co/u/Daniel6)
#### Post date: [August 5, 2019, 3:47am UTC](https://discuss.elastic.co/t/cors-problem-in-kibana-map/193710/1 "2019-08-05T03:47:47Z")

</div>

Hi,  
I run ELK on liunx (CetnOS7) server in **intranet** environment.  
Because of intranet environment, all original Map in Kibana not work.  
So I want to use custom map in Kibana.  
I download map geojson file form [https://exploratory.io/map](https://exploratory.io/map)

I set this in `kibana.yml`:

```
#Custom Region Maps
map.regionmap:
  includeElasticMapsService: false
  layers:
     - name: "World Map"
       url: "http://localhost:8080/world.geojson"
       attribution: "https://exploratory.io/map"
       fields:
          - name: "WORLD"
            description: "world map"

server.cors : true
server.cors.origin: "*"

```

The url is working because when I type in browser, it will download a file `world.geojson`

And set this in `elasticsearch.yml`

```
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: X-Requested-With, X-Auth-Token, Content-Type, Content-Length, kbn-version, Origin, Content-Type, Accept, Engaged-Auth-Token

```

But when I open Maps in Kibana, it shows **blank background**.  
And when I open region map in Kibana-Visualize, it also shows blank background with:

```
Error downloading vector data
Cannot download World Map file. Please ensure the CORS configuration of the server permits requests from the Kibana application on this host

```

How could I fix it?  
Thank you!

---

<div class="post-metadata">

### Author: ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)
#### Post date: [August 5, 2019, 3:01pm UTC](https://discuss.elastic.co/t/cors-problem-in-kibana-map/193710/2 "2019-08-05T15:01:27Z")

</div>

It looks like you may have specified the fields incorrectly in your `kibana.yml`. There is no `WORLD` attribute in the [exploratory.io](http://exploratory.io) World Map GeoJSON file. The `fields` definition refers to the attributes in the GeoJSON file.

---

<div class="post-metadata">

### Author: ![Daniel6](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@Daniel6](https://discuss.elastic.co/u/Daniel6)
#### Post date: [August 6, 2019, 1:30am UTC](https://discuss.elastic.co/t/cors-problem-in-kibana-map/193710/3 "2019-08-06T01:30:56Z")

</div>

Hi nickpeohl,  
I found official documents about:

> `fields:`  
> Mandatory. Each layer can contain multiple fields to indicate what properties from the geojson features you wish to expose. The example above shows how to define multiple properties.
> 
> `fields.name:`  
> Mandatory. This value is used to do an inner-join between the document stored in Elasticsearch and the geojson file. e.g. if the field in the geojson is called `Location` and has city names, there must be a field in Elasticsearch that holds the same values that Kibana can then use to lookup for the geoshape data.
> 
> `fields.description:`  
> Mandatory. The human readable text that is shown under the Options tab when building the Region Map visualization

In tutorial example from [Custom Region Maps in Kibana 6.0 | Elastic Blog](https://www.elastic.co/cn/blog/custom-region-maps-in-kibana-6-0)

It's setting in `kibana.yml` is:

```
# Custom Region Maps
regionmap:
  layers:
     - name: "Australian States"
       url: "http://localhost:8000/aus_state.geojson"
       attribution: "https://exploratory.io/maps"
       fields:
          - name: "STATE_NAME"
            description: "State Name"

```

And it's `aus_state.geojson` file has fields like this:

```
"properties": {
        "STATE_CODE": "1",
        "STATE_NAME": "New South Wales",
        "rmapshaperid": 0
      },
"id": 0

```

So I change my setting in `kibana.yml`:

```
#Custom Region Maps
map.regionmap:
  includeElasticMapsService: false
  layers:
     - name: "World Map"
       url: "http://localhost:8080/world.geojson"
       attribution: "https://exploratory.io/map"
       fields:
          - name: "NAME"
            description: "country name"

```

Where my `world.geojson` file has fields like this

```
 "properties": {
        "NAME": "Afghanistan",
        "NAME_LONG": "Afghanistan",
        "ADM0_A3": "AFG",
        "ISO_A2": "AF",
        "ISO_A3": "AFG",
        "WB_A2": "AF",
        "WB_A3": "AFG"
      },
 "id": 1

```

But it still shows same **CORS** error message.  
Where is the problem?  
Thank you!

---

<div class="post-metadata">

### Author: ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)
#### Post date: [August 6, 2019, 3:04pm UTC](https://discuss.elastic.co/t/cors-problem-in-kibana-map/193710/4 "2019-08-06T15:04:41Z")

</div>

What are you using to host the local GeoJSON file?

In the [blog post](https://www.elastic.co/cn/blog/custom-region-maps-in-kibana-6-0) we give an example of using `http-server --cors='*' -p 8000`. But I've found that `http-server --cors="kbn-version" -p 8000` works better.

---

<div class="post-metadata">

### Author: ![Daniel6](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@Daniel6](https://discuss.elastic.co/u/Daniel6)
#### Post date: [August 7, 2019, 6:07am UTC](https://discuss.elastic.co/t/cors-problem-in-kibana-map/193710/5 "2019-08-07T06:07:22Z")

</div>

Hi nickpeihl,  
Because of intranet environment, It' unable to install http-server by using `npm install http-server -g` like what they do in [tutorial](https://www.npmjs.com/package/http-server).

And I can't find any other way to install http-server, so I use **Wildfly** to host the local GeoJSON file.

---

<div class="post-metadata">

### Author: ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)
#### Post date: [August 7, 2019, 3:25pm UTC](https://discuss.elastic.co/t/cors-problem-in-kibana-map/193710/6 "2019-08-07T15:25:09Z")

</div>

At a minimum you should make sure CORS is enabled in your Wildfly server and that it accepts the `kbn-version` header. Unfortunately, I'm not familiar with Wildfly so I do not know how this CORS is configured.

---

<div class="post-metadata">

### Author: ![Daniel6](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@Daniel6](https://discuss.elastic.co/u/Daniel6)
#### Post date: [August 8, 2019, 8:06am UTC](https://discuss.elastic.co/t/cors-problem-in-kibana-map/193710/7 "2019-08-08T08:06:27Z")

</div>

Hi nickpeihl,  
Thanks for your advice about `make sure CORS is enabled` and `accepts the kbn-version header`.

I will study for it.  
Thank You!!! 😀  
Daniel.

---

<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: [September 5, 2019, 8:06am UTC](https://discuss.elastic.co/t/cors-problem-in-kibana-map/193710/8 "2019-09-05T08:06:45Z")

</div>

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