gateway 报错 allowedOrigins cannot contain the special value "*"

简介: gateway 报错 allowedOrigins cannot contain the special value "*"
java.lang.IllegalArgumentException: When allowCredentials is true, allowedOrigins cannot contain 
the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" response 
header. To allow credentials to a set of origins, list them explicitly or consider using "allowedOriginPatterns" instead.
  at org.springframework.web.cors.CorsConfiguration.validateAllowCredentials(CorsConfiguration.java:460)
  Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
  |_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain][from www.fhadmin.cn]

问题原因,新版本的gateway 取消了allowedOrigins, 对应的变更为 allowedOriginPatterns

配置修改为:

#--------gateway配置---fhadmin.cn-----
#使用服务发现路由
spring.cloud.gateway.discovery.locator.enabled=true
#服务路由名小写
spring.cloud.gateway.discovery.locator.lower-case-service-id=true
#跨域配置(java  fhadmin.cn)
spring.cloud.gateway.globalcors.corsConfigurations.[/**].allowedOriginPatterns=*
spring.cloud.gateway.globalcors.corsConfigurations.[/**].allowedHeaders=*
spring.cloud.gateway.globalcors.corsConfigurations.[/**].allowedMethods=*
spring.cloud.gateway.globalcors.corsConfigurations.[/**].allowCredentials=true

 

目录
相关文章
|
5月前
|
Java API Spring
Gateway网关报错Unable to start ServletWebServerApplicationContext due to missing ServletWebServer
Gateway网关报错Unable to start ServletWebServerApplicationContext due to missing ServletWebServer
92 0
|
6月前
|
监控
gateway 这样设置报错503 ,如何优化参数
当使用Hystrix时,根据您的错误信息,您可能需要调整一些参数来优化性能和解决503错误。以下是一些建议: 1. 调整`semaphore.maxConcurrentRequests`参数:这是控制允许并发请求的最大数量。检查您的应用程序负载和系统资源,并将其适当调整为适合您的情况。如果并发请求量很大,您可能需要增加该值。 2. 调整`timeoutInMilliseconds`参数:这是设置Hystrix命令的超时时间。如果您的服务响应时间很长,您可能需要增加该值以避免超时。确保将超时时间设置为适当的值,以便允许足够的时间来完成请求。 3. 调整`circuitBreaker.sle
100 0
|
负载均衡 Java Nacos
spring cloud 2020 gateway 报错503
spring cloud 2020 gateway 报错503
611 0
|
15天前
|
负载均衡 Nacos 数据安全/隐私保护
SpringCloud GateWay 使用
SpringCloud GateWay 使用
21 0
|
1月前
|
缓存 Java API
【云原生】Spring Cloud Gateway的底层原理与实践方法探究
【云原生】Spring Cloud Gateway的底层原理与实践方法探究
|
2月前
|
监控 Java 应用服务中间件
网关大解密:探索Spring Cloud Alibaba中Gateway的奥秘
网关大解密:探索Spring Cloud Alibaba中Gateway的奥秘
108 1
|
3月前
|
Java Spring
Spring Cloud Alibaba - 26 Gateway-自定义谓词工厂RoutePredicateFactory
Spring Cloud Alibaba - 26 Gateway-自定义谓词工厂RoutePredicateFactory
55 0
|
4月前
|
Java 数据安全/隐私保护 数据格式
Spring Cloud Gateway 网关整合 Knife4j 4.3 实现微服务接口文档聚合
Spring Cloud Gateway 网关整合 Knife4j 4.3 实现微服务接口文档聚合
|
1月前
|
SpringCloudAlibaba Java 网络架构
【Springcloud Alibaba微服务分布式架构 | Spring Cloud】之学习笔记(七)Spring Cloud Gateway服务网关
【Springcloud Alibaba微服务分布式架构 | Spring Cloud】之学习笔记(七)Spring Cloud Gateway服务网关
90 0
|
15天前
|
JSON 安全 关系型数据库
SpringCloud Gateway 实现自定义全局过滤器 + JWT权限验证
SpringCloud Gateway 实现自定义全局过滤器 + JWT权限验证

热门文章

最新文章