首页 > 其他分享 >16.设置允许跨域

16.设置允许跨域

时间:2023-03-01 21:14:27浏览次数:47  
标签:跨域 corsConfiguration 16 CorsConfiguration source new 允许 public

 

 

@Configuration
public class BianenCorsConfiguration {
    @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,16,CorsConfiguration,source,new,允许,public
From: https://www.cnblogs.com/cheng8/p/17169770.html

相关文章