问题描述
在用我的招摇网关设置cors并在zuul机制网关上运行时,我遇到一个奇怪的问题,其中包含微服务列表。单击它会重定向到特定的服务swagger文档,当我使用swagger的“试用”功能时。 This is how swagger gateway list looks like
问题是“尝试一下”调用选项方法调用以检查跨源操作并失败401。
例如。
这是我招摇的网关网址
abc.com/replica-stock/swagger-ui.html
zuul将其转换为下一个
replica-stock.com/swagger-ui.html
,对于“试用” api,请检查URL是否是这样
xyz.com/api/v1/getStock
我在浏览器控制台中遇到以下错误
Access to fetch at 'xyz.com/api/v1/getStock' from origin 'abc.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
这是我的请求和响应标头
请求标头
:method: OPTIONS
:path: /replica-stock/api/v1/replicaStocks/13?partCode=1234&usageCode=01
:scheme: https
accept: */*
accept-encoding: gzip,deflate,br
accept-language: en-IN,en-US;q=0.9,en-GB;q=0.8,en;q=0.7
access-control-request-headers: authorization
access-control-request-method: GET
origin: abc.com
referer: abc.com/replica-stock/swagger-ui.html
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: same-site
响应头
access-control-allow-credentials: true
access-control-allow-headers: authorization
access-control-allow-methods: GET
access-control-allow-origin: abc.com
allow: GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH
content-length: 0
content-type: application/json;charset=ISO-8859-1
date: Mon,17 Aug 2020 06:16:20 GMT
status: 401
vary: Origin
vary: Access-Control-Request-Method
vary: Access-Control-Request-Headers
x-vcap-request-id: 2b52f4f7-085f-449e-5429-ffbd830cd5db
有人可以帮我解决这个问题吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)