使用Spring
Security时,建议使用CorsFilter。您将要确保订购
CorsFilterSpring
Security之前的产品
FilterChainProxy。
对于此问题,可能只需要注册注销URL即可。例如:
@Beanpublic CorsFilter corsFilter() { UrlbasedCorsConfigurationSource source = new UrlbasedCorsConfigurationSource(); CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); // you USUALLY want this // likely you should limit this to specific origins config.addAllowedOrigin("*"); config.addAllowedHeader("*"); config.addAllowedMethod("GET"); config.addAllowedMethod("POST"); config.addAllowedMethod("PUT"); source.registerCorsConfiguration("/logout", config); return new CorsFilter(source);}


