woshitom
woshitom

Reputation: 5131

Elasticsearch blocked by CORS policy depends on the query

I'm using a search query (query is pretty long) it works when my search term is in latin character but as soon as I input some Thai characters I'm getting the following error:

Access to XMLHttpRequest at 'xxxxxxx' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I don't get how it is related to CORS policy because same query works with latin characters. Same query with Thai characters works fine in Kibana. Other queries (smaller) with Thai characters as input works also well from my frontend.

Any idea what could be the blocker?

Upvotes: 2

Views: 805

Answers (1)

hamid bayat
hamid bayat

Reputation: 2179

add these lines to elasticsearch.yml and resteart the service:

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

some options of above are default but it has no harm to clarify. first two lines are important.

more information: https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-http.html

Upvotes: 2

Related Questions