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.org]

問題原因,新版本的gateway 取消了allowedOrigins, 對應的變更為 allowedOriginPatterns
配置修改為:
#--------gateway配置--------
#使用服務發現路由
spring.cloud.gateway.discovery.locator.enabled=true
#服務路由名小寫
spring.cloud.gateway.discovery.locator.lower-case-service-id=true
#跨域配置(java www.fhadmin.org)
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

一:springcloud服務 -----------------------
java www.fhadmin.org
------------------------------------------
1.nacos 阿里注冊中心:官方eureka停止更新,目前比較好的取代者就是nacos
2.zipkin 跟蹤服務:分布式跟蹤日志,基于記憶體存盤記錄
3.gateway 網關路由服務:分發請求,統一管理過濾,結合 ribbon 負載均衡、feign服務呼叫
4.springboot-admin 監控中心服務:統一界面管理,查看各個服務運行狀態 actuator健康檢查
5.sentinel 高可用流量管理框架:以流量為切入點,限流、流量整形、熔斷降級、系統負載保護、熱點防護
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/285550.html
標籤:Java
上一篇:圖解 Kafka,畫得太好了!
