Spring Cloud Gateway跨域配置 - 配置后无效解决办法


版本:Greenwich.SR2 + 

 

1.官网配置

https://cloud.spring.io/spring-cloud-static/spring-cloud-gateway/2.2.1.RELEASE/reference/html/#cors-configuration

给个例子:

spring:
  cloud:
      gateway:
        globalcors:
           cors-configurations:
               '[/**]':
                  allowCredentials: true
                  allowedOrigins: "*"
                  allowedMethods: "*"
                  allowedHeaders: "*"

 

 

2.配置以后无效

查看响应信息

 

 

 

 

发现有多条

 

原因:

网关配置了跨域,服务里也配置了跨域。

解决办法:

去除服务里的配置

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM