微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

请求已被 CORS 策略阻止:对预检请求的响应未通过 Apache Druid 中的访问控制检查

如何解决请求已被 CORS 策略阻止:对预检请求的响应未通过 Apache Druid 中的访问控制检查

我正在尝试从我的 Angular SPA 中的 Apache Druid 服务器请求数据,并遇到与 CORS 配置相关的下一个问题:

Access to XMLHttpRequest at URL from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
SERVER_URL:8889/druid/v2/?pretty:1 Failed to load resource: net::ERR_Failed

据我从 documentation 中了解到,我必须更改配置文件中的下一组属性

druid.auth.allowUnauthenticatedHttpOptions=true
druid.server.http.allowedHttpMethods =["POST","GET","OPTIONS"]

但即使在此之后,由于问题,我仍然无法从 Druid API 检索任何数据。

我还试图通过将下一个 extension 添加到 Apache Druid 配置来解决该问题:

druid.extensions.coordinates=["net.acesinc.druid.extensions:cors-servlet-filter:1.0.0"]

但它也没有改变任何东西。

有人知道我做错了什么,或者我如何用 CORS 解决这个问题?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。