问题描述
今天在windows
上使用head
插件连接elasticsearch
,老是连不上,换了好几个端口都不行。
打开chrome控制台,发现一大堆报错:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:9100' is therefore not allowed access.
明显是跨域出了问题。
解决方法
在elasticsearch.yml
里面添加如下代码:
#开启跨域访问支持,默认为false
http.cors.enabled: true
#跨域访问允许的域名地址,(允许所有域名)以上使用正则
http.cors.allow-origin: /.*/
参考文章
https://blog.csdn.net/hhj724/article/details/52066199
https://www.ibm.com/support/knowledgecenter/zh/SSFPJS_8.5.6/com.ibm.wbpm.main.doc/topics/rfps_esearch_configoptions.html