```java
@Bean
public CorsWebFilter corsWebFilter(){
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration corsConfiguration = new CorsConfiguration();
//1、配置跨域
corsConfiguration.addAllowedHeader("*"); // 允许任何头
corsConfiguration.addAllowedMethod("*"); // 允许任何方法(post、get等)
corsConfiguration.addAllowedOrigin("*");// 允许任何域名使用
corsConfiguration.setAllowCredentials(true);//允许携带cookie访问
source.registerCorsConfiguration("/**",corsConfiguration);
return new CorsWebFilter(source);
}
gateway里配置跨域类,解决跨域问题
最新推荐文章于 2024-05-20 11:02:57 发布