修復(fù)zuul跨域配置異常

本文主要介紹一下在zuul進(jìn)行跨域配置的時(shí)候出現(xiàn)的異常。

異常

The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed

實(shí)例

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

方案

多次請(qǐng)求的時(shí)候,會(huì)把這些header再帶過來,然后請(qǐng)求zuul轉(zhuǎn)發(fā)的接口又在寫入一次,造成重復(fù)了,方案就是zuul轉(zhuǎn)發(fā)的時(shí)候,過濾掉這些header,比如

zuul:
  sslHostnameValidationEnabled: false  
  routes:
    info:
      sensitiveHeaders: Access-Control-Allow-Origin,Access-Control-Allow-Methods
      path: /share/**
      url: http://192.168.99.100:9000/

doc

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容