跨源请求已阻止:同源策略禁止在http://localhost:8080/index/home上读取远程资源。 (原因:缺少CORS标题'Access-Control-Allow-Origin')。
客户端运行在8000
休息服务在8080运行,服务有@CrossOrigin(originins =“http://localhost:8000/”)
但仍然没有工作
@Bean
public CorsFilter corsFilter() {
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
final CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("OPTIONS");
config.addAllowedMethod("HEAD");
config.addAllowedMethod("GET");
config.addAllowedMethod("PUT");
config.addAllowedMethod("POST");
config.addAllowedMethod("DELETE");
config.addAllowedMethod("PATCH");
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}