import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.web.cors.CorsConfiguration;
    import org.springframework.web.cors.reactive.CorsWebFilter;
    import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
    import org.springframework.web.util.pattern.PathPatternParser;

    @Configuration
    public class CorsConfig {
    @Bean
    public CorsWebFilter corsFilter() {
    CorsConfiguration config = new CorsConfiguration();
    config.addAllowedMethod(““);
    config.addAllowedOrigin(“
    “);
    config.addAllowedHeader(“*”);

    1. //api的接口不设置跨域<br /> UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());<br /> source.registerCorsConfiguration("/account/**", config);<br /> source.registerCorsConfiguration("/company/**", config);<br /> source.registerCorsConfiguration("/link/**", config);<br /> source.registerCorsConfiguration("/workflow/**", config);<br /> source.registerCorsConfiguration("/personal/**", config);<br /> source.registerCorsConfiguration("/official/**", config);<br /> source.registerCorsConfiguration("/sign/**", config);<br /> source.registerCorsConfiguration("/template/**", config);<br /> source.registerCorsConfiguration("/contract/**", config);<br /> source.registerCorsConfiguration("/v1/3rd/**", config);<br /> source.registerCorsConfiguration("/sms/**", config);
    2. return new CorsWebFilter(source);<br /> }<br />}