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

 

目录
相关文章
|
11月前
|
Java API Spring
Gateway网关报错Unable to start ServletWebServerApplicationContext due to missing ServletWebServer
Gateway网关报错Unable to start ServletWebServerApplicationContext due to missing ServletWebServer
223 0
|
2月前
|
SQL DataWorks 关系型数据库
DataWorks操作报错合集之如何解决临时查询报错:None Active Gateway Resource
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
|
监控
gateway 这样设置报错503 ,如何优化参数
当使用Hystrix时,根据您的错误信息,您可能需要调整一些参数来优化性能和解决503错误。以下是一些建议: 1. 调整`semaphore.maxConcurrentRequests`参数:这是控制允许并发请求的最大数量。检查您的应用程序负载和系统资源,并将其适当调整为适合您的情况。如果并发请求量很大,您可能需要增加该值。 2. 调整`timeoutInMilliseconds`参数:这是设置Hystrix命令的超时时间。如果您的服务响应时间很长,您可能需要增加该值以避免超时。确保将超时时间设置为适当的值,以便允许足够的时间来完成请求。 3. 调整`circuitBreaker.sle
195 0
|
负载均衡 Java Nacos
spring cloud 2020 gateway 报错503
spring cloud 2020 gateway 报错503
664 0
|
1月前
|
负载均衡 Java Nacos
SpringCloud基础2——Nacos配置、Feign、Gateway
nacos配置管理、Feign远程调用、Gateway服务网关
SpringCloud基础2——Nacos配置、Feign、Gateway
|
28天前
|
Java 开发者 Spring
Spring Cloud Gateway 中,过滤器的分类有哪些?
Spring Cloud Gateway 中,过滤器的分类有哪些?
25 3
|
1月前
|
负载均衡 Java 网络架构
实现微服务网关:Zuul与Spring Cloud Gateway的比较分析
实现微服务网关:Zuul与Spring Cloud Gateway的比较分析
55 5
|
16天前
|
负载均衡 Java API
【Spring Cloud生态】Spring Cloud Gateway基本配置
【Spring Cloud生态】Spring Cloud Gateway基本配置
29 0
|
1月前
|
安全 Java 开发者
强大!Spring Cloud Gateway新特性及高级开发技巧
在微服务架构日益盛行的今天,网关作为微服务架构中的关键组件,承担着路由、安全、监控、限流等多重职责。Spring Cloud Gateway作为新一代的微服务网关,凭借其基于Spring Framework 5、Project Reactor和Spring Boot 2.0的强大技术栈,正逐步成为业界的主流选择。本文将深入探讨Spring Cloud Gateway的新特性及高级开发技巧,助力开发者更好地掌握这一强大的网关工具。
162 6
|
3月前
|
负载均衡 Java Spring
Spring cloud gateway 如何在路由时进行负载均衡
Spring cloud gateway 如何在路由时进行负载均衡
427 15