gpt4 book ai didi

javascript - ElasticSearch Access-Control-Allow-Headers header 不存在

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:41:36 28 4
gpt4 key购买 nike

我正在从本地 https 服务器向配置如下的 ElasticSearch 端点发出 POST 请求

http.cors.enabled: true
http.cors.allow-credentials: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: X-Requested-With, X-Auth-Token, Content-Type, Content-Length, Authorization, Access-Control-Allow-Headers, Accept

请求有 header :

Access-Control-Allow-Headers: Accept, Access-Control-Allow-Headers, Authorization, Content-Type
Content-Type: application/json; charset=utf-8
Accept: application/json; charset=utf-8
Access-Control-Allow-Credentials: true
Authorization: (basic authentication token)

在 POST 请求中,出现以下错误:请求 header 字段 Access-Control-Allow-Headers is not allowed by Access-Control-Allow-Headers in preflight response。

网络调试器确实显示响应 header 中不存在 Access-Control-Allow-Headers header 。响应头:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: https://dl.dropboxusercontent.com
Vary: Origin
Access-Control-Allow-Methods:
Access-Control-Allow-Credentials: true
Access-Control-Max-Age: 1728000
content-length: 0
date: Fri, 29 Apr 2016 14:08:14 GMT

请注意,Access-Control-Allow-Headers 不存在并且 Access-Control-Allow-Methods 为空白。所有可能的字符串格式都已经过测试,不会出现这些标题。

最佳答案

您应该在 elasticsearch.yml 中添加以下标志:

http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers : Authorization, X-Requested-With,X-Auth-Token,Content-Type, Content-Length

然后重启es,尽情享受吧!

关于javascript - ElasticSearch Access-Control-Allow-Headers header 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36941100/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com