Reactjs ReactiveSearch(ReactiveJS)w/Elasticsearch CORS错误
我正在尝试将我的前端React应用程序与本地elasticsearch节点连接。我正在使用连接elasticsearch。我的服务器运行在Digital Ocean上,它运行的是Ubuntu 16.04。我按照他们的方法在服务器上运行elasticsearch,并在我的elasticsearch.yml文件中添加了以下行:Reactjs ReactiveSearch(ReactiveJS)w/Elasticsearch CORS错误,reactjs,
elasticsearch,cors,reactivesearch,Reactjs,
elasticsearch,Cors,Reactivesearch,我正在尝试将我的前端React应用程序与本地elasticsearch节点连接。我正在使用连接elasticsearch。我的服务器运行在Digital Ocean上,它运行的是Ubuntu 16.04。我按照他们的方法在服务器上运行elasticsearch,并在我的elasticsearch.yml文件中添加了以下行: http.cors.enabled:true http.cors.allow-origin:“*” http.cors.allow-methods:选项、HEAD、GET、P
http.cors.enabled:true
http.cors.allow-origin:“*”
http.cors.allow-methods:选项、HEAD、GET、POST、PUT、DELETE
http.cors.allow-headers:X-Requested-With,X-Auth-Token,内容类型,内容长度
我的ReactJS组件看起来与ReactiveSearch getting started所说的完全一样:
<ReactiveBase
app="users"
url="http://localhost:9200">
<DataSearch
componentId="SearchSensor"
dataField={["email", "username", "name"]}
title="Search"
placeholder="Search for users..."
/>
</ReactiveBase>
但是,如果我转到url:http://localhost:9200/users/active/1
它实际起作用并显示该对象:
{u index:“用户”,“u类型”:“活动”,“u id”:“1”,“u版本”:1,“找到”:true,{u源”:{“名称”:“Jon Stevens”,“电子邮件”:jon@vendorpay.io“}}
这到底是怎么回事??非常感谢您的帮助
请求/控制台屏幕截图:
当您在msearch请求URL上省略类型时会发生什么?相同的结果:
{“错误”:{“根本原因”:[{“类型”:“解析异常”,“原因”:“未能派生xcontent”}],“类型”:“解析异常”,“原因”:“未能派生xcontent”},“状态”:400}
,通常来自格式错误的请求。对于MSSearch端点,内容类型标头应设置为application/x-ndjson。你试过使用邮递员或卷发吗?邮递员和卷发给我的结果都一样。此外,更改标题将意味着修改节点\ u模块中的包。
。在《邮递员》中,我尝试将内容类型
标题更改为应用程序/x-ndjson
,结果仍然相同。
{"error":{"root_cause":[{"type":"parse_exception","reason":"Failed to derive xcontent"}],"type":"parse_exception","reason":"Failed to derive xcontent"},"status":400}