我正在尝试使用 axios 在 kibana React 客户端中获取自定义标头设置的值,以响应我们的服务器,但即使它显示在浏览器控制台中,它似乎也无法访问(还设置了 Access-Control-Expose-Headers ).
我的问题是 kibana 中是否有某种配置可以阻止客户端访问自定义标头。谢谢。
http.cors。以下是您需要添加 elasticsearch.yml
的值:
http.cors.enabled: true
http.cors.allow-credentials: true
http.cors.allow-origin: "*"
http.cors.allow-headers: "*"
http.cors.allow-methods: "OPTIONS,HEAD,GET,POST,PUT,DELETE"
此外,您还可以通过以下 API 调用检查当前设置。
GET _cluster/settings?include_defaults&filter_path=**.cors
示例输出:
{
"defaults": {
"http": {
"cors": {
"max-age": "1728000",
"allow-origin": "*",
"allow-headers": "*",
"allow-credentials": "true",
"allow-methods": "OPTIONS,HEAD,GET,POST,PUT,DELETE",
"enabled": "true"
}
}
}
}
出于安全原因,建议纳入适当的限制。