springboot跨域问题

Application 类配置 如下:

@Configuration

publicclassCorsConfig {

    privateCorsConfiguration buildConfig() {

        CorsConfiguration corsConfiguration = newCorsConfiguration();

        corsConfiguration.addAllowedOrigin("*");

        corsConfiguration.addAllowedHeader("*");

        corsConfiguration.addAllowedMethod("*");

        returncorsConfiguration;

    }


    @Bean

    publicCorsFilter corsFilter() {

        UrlBasedCorsConfigurationSource source = newUrlBasedCorsConfigurationSource();

        source.registerCorsConfiguration("/**", buildConfig());

        returnnewCorsFilter(source);

    }

}

你可能感兴趣的:(springboot跨域问题)