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

刺骨的言语ヽ痛彻心扉 2022-10-19 11:27 127阅读 0赞
  1. java.lang.IllegalArgumentException: When allowCredentials is true, allowedOrigins cannot contain
  2. the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" response
  3. header. To allow credentials to a set of origins, list them explicitly or consider using "allowedOriginPatterns" instead.
  4. at org.springframework.web.cors.CorsConfiguration.validateAllowCredentials(CorsConfiguration.java:460)
  5. Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
  6. Error has been observed at the following site(s):
  7. |_ checkpoint org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain][from www.fhadmin.cn]

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

配置修改为:

  1. #--------gateway配置---fhadmin.cn-----
  2. #使用服务发现路由
  3. spring.cloud.gateway.discovery.locator.enabled=true
  4. #服务路由名小写
  5. spring.cloud.gateway.discovery.locator.lower-case-service-id=true
  6. #跨域配置(java www.fhadmin.org)
  7. spring.cloud.gateway.globalcors.corsConfigurations.[/**].allowedOriginPatterns=*
  8. spring.cloud.gateway.globalcors.corsConfigurations.[/**].allowedHeaders=*
  9. spring.cloud.gateway.globalcors.corsConfigurations.[/**].allowedMethods=*
  10. spring.cloud.gateway.globalcors.corsConfigurations.[/**].allowCredentials=true

发表评论

表情:
评论列表 (有 0 条评论,127人围观)

还没有评论,来说两句吧...

相关阅读