来自Elasticsearch中的CORS预检通道的Cors标头“ Access-Control-Allow-Headers”中的令牌“内容类型”缺失

Ash*_*thu 9 cors elasticsearch

我正在尝试构建一个社交应用程序。我正在使用MEANJS样板。并很好地处理请求。但是当涉及到搜索时,我想将ElasticSearch集成到该MEAN应用程序中。

因此,我按照 http://www.sitepoint.com/building-recipe-search-site-angular-elasticsearch/ 链接进行了初始设置。我编写了控制器,并成功将mongodb模型建立了索引,从而可以成功地弹性搜索数据库。

我通过查询模型转到localhost:9200验证了弹性搜索。我的意思是js应用程序正在localhost:3000中运行。

一切都很好,但是阻止我的一件事是CORS。通过弹性搜索进行CORS配置以获得结果。这是我从localhost:3000到localhost 9200的请求 要允许CORS,我必须配置我的elasticsearch yaml文件。我通过添加

 http.cors.enabled : true
  http.cors.allow-origin : "*"
  http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE
  http.cors.allow-headers : origin, X-Auth-Token,Content-Type, accept
  http.cors.Max-Age: "1728000"
Run Code Online (Sandbox Code Playgroud)

但是我仍然无法访问localhost:9200服务器。

我得到这个错误。

任何详细的帮助表示赞赏。谢谢!

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:9200/. (Reason: missing token 'content-type' in CORS header 'Access-Control-Allow-Headers' from CORS preflight channel).
Run Code Online (Sandbox Code Playgroud)