# Enable cors in a kibana api in a docker container

**URL:** <https://discuss.elastic.co/t/enable-cors-in-a-kibana-api-in-a-docker-container/195266>\
**Category:** Kibana\
**Tags:** docker\
**Created:** [August 14, 2019, 8:55pm UTC](https://discuss.elastic.co/t/enable-cors-in-a-kibana-api-in-a-docker-container/195266 "2019-08-14T20:55:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![glaucomorandini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/glaucomorandini/32/52324_2.png) [@glaucomorandini](https://discuss.elastic.co/u/glaucomorandini)\
**Post date:** [August 14, 2019, 8:55pm UTC](https://discuss.elastic.co/t/enable-cors-in-a-kibana-api-in-a-docker-container/195266/1 "2019-08-14T20:55:20Z")

</div>

Hey guys, I created a docker container with kibana, and I'm trying to access the kibana api from another origin/host through JS, but the api raises an error, because the cors is not enabled.

The error:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/b/cb2f76e801c3e8addb80f6b0d853256a9a16a629.png)

My kibana.yml:

```
---
## Default Kibana configuration from kibana-docker.
## https://github.com/elastic/kibana-docker/blob/master/.tedi/template/kibana.yml.j2
#
server.name: kibana
server.host: "0"
elasticsearch.hosts: ["http://elasticsearch:9200"]
xpack.monitoring.ui.container.elasticsearch.enabled: true

## X-Pack security credentials
#
elasticsearch.username: elastic
elasticsearch.password: changeme

## enable cors
server.cors: true
server.cors.origin: ["*"]

```

My js request:

```
$.ajax({
  method: "POST",
  url: "http://localhost:5601/api/security/v1/login",
  dataType: "json",
  headers: {
      "kbn-xsrf": "7.3.0",
      'Content-Type': 'application/json'},
  data: JSON.stringify({
    "username": 'elastic',
    "password": 'changeme'
  }),
  success: function (success) {
    console.log("opa deu certo");
  },
  error: function (error) { console.log("error login kibana"); }
});

```

docker-compose.yml

```
kibana:
  image: docker.elastic.co/kibana/kibana:7.3.0
  container_name: kibana
  hostname: kibana
  environment:
    - SERVER_NAME=kibana
    - ELASTICSEARCH_URL=http://elasticsearch:9200
    - ELASTICSEARCH_PORT=9200
    - ELASTIC_PWD=changeme
    - KIBANA_PWD=changeme
  volumes:
    - ./kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml:rw
  ports:
    - "5601:5601"
  links:
    - elasticsearch

```

I looked at this [post](https://discuss.elastic.co/t/unable-to-perform-login-on-kibana-throught-browser-javascript-api-call/189345), and I tried to make it work, I wasn't successful.

What I have to do, to fix this problem?

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [August 16, 2019, 1:40pm UTC](https://discuss.elastic.co/t/enable-cors-in-a-kibana-api-in-a-docker-container/195266/2 "2019-08-16T13:40:57Z")

</div>

@jbudz please thank you!

---

<div class="post-metadata">

**Author:** ![jbudz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbudz/32/45922_2.png) [@jbudz](https://discuss.elastic.co/u/jbudz)\
**Post date:** [August 19, 2019, 7:14pm UTC](https://discuss.elastic.co/t/enable-cors-in-a-kibana-api-in-a-docker-container/195266/3 "2019-08-19T19:14:52Z")

</div>

Hey, cors support is fairly limited right now. There's an open issue at [https://github.com/elastic/kibana/issues/16714](https://github.com/elastic/kibana/issues/16714). Settings CORS to true will enable support for GET requests, but to get around this you'll likely need a reverse proxy

---

<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 16, 2019, 7:14pm UTC](https://discuss.elastic.co/t/enable-cors-in-a-kibana-api-in-a-docker-container/195266/4 "2019-09-16T19:14:56Z")

</div>

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