网关统一配置跨域
作者:互联网
网关微服务 统一配置跨域
public class GulimallCorsConfiguration { @Bean public CorsWebFilter corsWebFilter(){ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration corsConfiguration = new CorsConfiguration(); corsConfiguration.addAllowedHeader("*"); corsConfiguration.addAllowedMethod("*"); corsConfiguration.addAllowedOrigin("*"); corsConfiguration.setAllowCredentials(true); //对进入网关的所有请求都注册这个跨域配置 source.registerCorsConfiguration("/**",corsConfiguration); return new CorsWebFilter(source); } }
标签:网关,跨域,corsConfiguration,配置,source,CorsConfiguration,new 来源: https://www.cnblogs.com/houchen/p/15318069.html