0
我的過濾器具有以下配置。在向CORBA請求localhost:8080/oauth/token
發出請求時,請求似乎無法完成。CORS過濾器不適用於彈簧oauth /令牌
@Bean
public FilterRegistrationBean corsFilter() {
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*"); // @Value: http://localhost:8080
config.addAllowedHeader("*");
config.addAllowedMethod("*");
source.registerCorsConfiguration("/**", config);
FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
bean.setOrder(-1);
return bean;
}
@Override
protected void configure(HttpSecurity http) throws Exception{
http.csrf().disable().authorizeRequests().antMatchers(HttpMethod.OPTIONS, "/oauth/token").permitAll().antMatchers(HttpMethod.OPTIONS, "/**").permitAll();
}
我錯過了我的配置中的東西嗎?