How to Enable CORS (Cross Origin Resource Sharing)

I tried to put this in docker-compose.yml but didn’t work.

- bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
- “ES_JAVA_OPTS=-Xms512m -Xmx512m” # minimum and maximum Java heap size, recommend setting both to 50% of system RAM

  - http.cors.enabled=true
  - http.cors.allow-origin=http://localhost:1358,
  - http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
  - http.cors.allow-credentials=true
  - opendistro_security.ssl.http.enabled=false

Does Open Distro supports CORS with different config keys like or it is currently impossible?


i am also getting the same problem .Do you find any solution.

Did you ever figure this out?

You need to put the following in opensearch.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

I copied mine from the container and then used a bind mount. If anyone figures out how to do this via the docker-compose.yaml that would be preferred, but this worked for me.