你好,我正在运行 Elasticsearch 2.3 版本,并且有一段 Angular 代码用于查询搜索。当我运行它时,即使将 http.cors.enabled 设置为 true,http.cors.allow-origin 设置为 /https?:\/\/localhost(:[0-9]+)?/
,我仍然遇到了这个错误。
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://localhost:9200/elastic/_search?size=50. This can be fixed by moving the resource to the same domain or enabling CORS
我不明白问题出在哪里。
我的请求头。
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0
Pragma: no-cache
Origin: http://127.0.0.1:8100
Host: localhost:9200
Connection: keep-alive
Cache-Control: no-cache
Access-Control-Request-Method: POST
Access-Control-Request-Headers: content-type
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
我的控制台看起来像这样。
![输入图像描述](https://istack.dev59.com/o5jhG.webp)
![输入图像描述](https://istack.dev59.com/uCR6v.webp)