gpt4 book ai didi

cors - quarkus:受CORS政策封锁

转载 作者:行者123 更新时间:2023-12-03 14:33:42 32 4
gpt4 key购买 nike

尽管我配置了属性文件,但仍然收到错误消息:

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.

I also created a @Provider extending ContainerRequestFilter, but it never reaches there



application.properties
# Configuration file
quarkus.http.port=9090
quarkus.http.cors=true
quarkus.http.origins=http://localhost:4200, localhost:9090
quarkus.http.headers=accept, authorization, content-type, x-requested-with
quarkus.http.methods=GET, OPTIONS

已编辑
17:11:09 WARN  [io.qu.config]] (build-3) Unrecognized configuration key "quarkus.http.methods" provided
17:11:09 WARN [io.qu.config]] (build-3) Unrecognized configuration key "quarkus.http.headers" provided
17:11:09 WARN [io.qu.config]] (build-3) Unrecognized configuration key "quarkus.http.origins" provided

最佳答案

警告是一个很好的指示。

您的配置不正确。

应该是这样的:

quarkus.http.cors.origins=http://localhost:4200,http://localhost:9090
quarkus.http.cors.headers=accept, authorization, content-type, x-requested-with
quarkus.http.cors.methods=GET, OPTIONS

带有 cors前缀。

我们现在没有适当的文档,所以最好引用 https://github.com/quarkusio/quarkus/blob/master/extensions/undertow/runtime/src/main/java/io/quarkus/undertow/runtime/filters/CORSConfig.java

我打开 https://github.com/quarkusio/quarkus/issues/3156来跟踪文档问题。

关于cors - quarkus:受CORS政策封锁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56959505/

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