跨域异常:XMLHttpRequest cannot load  ''. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' ' is therefore not allowed access. 

 

  做ES搜索的时候出现了以上问题,百度了一些方法,都不能解决,其中一个方法是在ajax内加入

dataType:"jsonp,虽能解决跨域问题,但是却出现了请求的数据不能识别,如下异常:

"type": "illegal_argument_exception",
"reason": "request [/books/book/1] contains unrecognized parameters: [_], [callback]"

最后请教一个大牛,顺利解决了,在ES的conf文件夹下的elasticsearch.yml文件内最下面加入下面两句话:

http.cors.enabled: true
http.cors.allow-origin: /http?:\/\/*.*.*.*(:[0-9]+)?/

 

 
                    
            
                

相关文章:

  • 2022-02-27
  • 2021-11-30
  • 2021-10-08
  • 2021-08-01
  • 2022-12-23
  • 2021-09-25
  • 2021-11-30
  • 2021-07-22
猜你喜欢
  • 2021-11-30
  • 2021-06-19
  • 2021-11-30
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
  • 2021-05-08
相关资源
相似解决方案