allowedOrigins cannot contain the special value "*" gateway

created at 07-10-2021 views: 2

description

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.example.com]

The cause of the problem, the new version of the gateway canceled allowedOrigins, and the corresponding change was allowedOriginPatterns

solution

The configuration is modified to:

#--------gateway configuration---example.com-----
#Use service discovery route
spring.cloud.gateway.discovery.locator.enabled=true
#Service route name lowercase
spring.cloud.gateway.discovery.locator.lower-case-service-id=true
#Cross-domain configuration (java www.example.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
Please log in to leave a comment.