我正在尝试构建社交应用。我正在使用MEANJS样板。和处理请求。但是当谈到搜索时,我想将ElasticSearch集成到这个MEAN应用程序中。
所以我跟着 http://www.sitepoint.com/building-recipe-search-site-angular-elasticsearch/ 初始设置的链接。我编写了控制器,并将我的mongodb模型成功编入弹性搜索数据库。
我通过查询模型转到localhost:9200来验证弹性搜索。 我的意思是js app在localhost:3000中运行。
一切都很好,但阻止我的一件事就是CORS。使用弹性搜索进行CORS配置以获得结果。this is my request from localhost:3000 to 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"
但我仍然无法访问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).