为什么我加了CorsFilter还是报cors跨域问题?

    @Bean

public CorsFilter corsFilter() {

CorsConfiguration corsConfiguration = new CorsConfiguration();

corsConfiguration.setAllowCredentials(true);

corsConfiguration.addAllowedOrigin("*");

corsConfiguration.addAllowedHeader("Content-Type, Authorization");

corsConfiguration.addAllowedMethod("PUT, POST, GET, OPTIONS, DELETE");

// corsConfiguration.addExposedHeader("head1");

//corsConfiguration.addExposedHeader("Location");

UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();

urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);

return new CorsFilter(urlBasedCorsConfigurationSource);

}

回答

要补一个特殊处理,如果method是OPTIONS 的话,直接200 返回

以上是 为什么我加了CorsFilter还是报cors跨域问题? 的全部内容, 来源链接: utcz.com/a/30310.html

回到顶部