首页 > 技术文章 > Spring Cloud Gateway跨域配置 - 配置后无效解决办法

tusheng 2020-02-03 16:31 原文

版本: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.配置以后无效

查看响应信息

 

 

 

 

发现有多条

 

原因:

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

解决办法:

去除服务里的配置

 

推荐阅读