愚者求师之过,智者从师之长。

kibana用$http发送post请求报错跨域问题

Kibana | 作者 captainayou | 发布于2018年02月08日 | 阅读数:4469



近期有个需求是,用户能一键导出所查询内容的所有数据(discover页面显示的只是部分,因此只好二次开发),我们自己搭了个后端,前端只是传递参数而已,但是会存在跨域的报错,同样的$http请求代码,放出kibana单独测试是没有问题的,代码及报错如下
LAE~_H(4V([T4SDR]BZ}4SJ.png

 
 
Failed to load http://192.:8080/elastic-web/e ... tion: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://10.1.106:5601' is therefore not allowed access.
已邀请:

xinfanwang

赞同来自:

elasticsearch.yml 配置允许跨域。


http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, Authorization"
 

要回复问题请先登录注册