我在我的Windows机器上运行弹性搜索,我可以curl -XGET "http://localhost:9200/movies/_search"
并获得一大堆对象。
当我尝试用角度请求var client = elasticsearch({ host: 'localhost:9200' });
时,我会得到以下内容。
XMLHttpRequest cannot load http://localhost:9200/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
我在elasticsearch.yml
内添加了
http.cors.allow-origin: "*"
http.cors.enabled: true
并尝试
http.cors.allow-origin: "/localhost(:[0-9]+)?/"