1. 程式人生 > 其它 >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 www.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

-------------------------www.fhadmin.cn-----------------------------------------自定義表單
28. 定義模版:拖拽左側表單元素到右側區域,編輯表單元素,儲存表單模版
29. 表單模版:編輯維護表單模版,複製表單模版,修改模版型別,預覽表單模版
30. 我的表單:選擇表單模版,編輯表單規則,是否上傳圖片、附件、開啟富文字、掛靠流程開關等
31. 表單資料:從我的表單進去可增刪改查表單資料,修改表單規則
32. 掛靠記錄:記錄表單資料和流程例項ID關聯記錄,可刪除