前言
本文主要给大家介绍一下在zuul进行跨域配置的时候出现异常该如何解决的方法,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧。
异常
1
|
The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed
|
实例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
Access-Control-Allow-Credentials: true
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin:http: //localhost:3000
Access-Control-Allow-Origin:http: //localhost:3000
Cache-Control:no-cache, no-store, max-age= 0 , must-revalidate
Content-Type:application/json;charset=UTF- 8
Date:Thu, 11 Aug 2016 14 : 23 : 09 GMT
Expires: 0
Pragma:no-cache
Transfer-Encoding:chunked
Vary:Origin
Vary:Origin
X-Application-Context:shipping-service:dev: 8080
X-Content-Type-Options:nosniff
X-Frame-Options:DENY
X-XSS-Protection: 1 ; mode=block
|
方案
多次请求的时候,会把这些header再带过来,然后请求zuul转发的接口又在写入一次,造成重复了,方案就是zuul转发的时候,过滤掉这些header,比如
1
2
3
4
5
6
7
|
zuul:
sslHostnameValidationEnabled: false
routes:
info:
sensitiveHeaders: Access-Control-Allow-Origin,Access-Control-Allow-Methods
path: /share/**
url: http: //192.168.99.100:9000/
|
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对服务器之家的支持。
doc
Zuul Access-Control-* Headers are duplicated
原文链接:https://segmentfault.com/a/1190000010722941