извините за поздний ответ
Вам просто нужно обновить конфигурацию ES
. Шаги:
Добавить этот код:
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-credentials: true
http.cors.allow-headers: "Authorization, X-Requested-With, Content-Type, Content-Length"
http.cors.allow-methods: "OPTIONS, HEAD, GET, POST, PUT, DELETE"
Код JS:
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://localhost:9200/_search', true);
xhr.withCredentials = true;
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Authorization', 'Basic ' + btoa('test:test'));
xhr.send('{"query":{"match_all":{}}}');
Если это состояние ответа 200, тогда попробуйте с помощью mirage.