将ngork映射到前端vue项目地址,前端数据可以正常访问,但是利用前端获取后端数据时报错
已经配置了后端跨域访问(不使用ngork前端可正常访问后端)
1)这是直接访问正常获取后端数据
2)这是利用ngork获取后端数据出现CORS报错,请求网址没有变化但是referer变了
为什么这个时候后端的跨域不起作用了?
@Configuration
public class YjmallConfiguration {
@Bean
public CorsWebFilter corsWebFilter(){
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration corsConfiguration = new CorsConfiguration();
//1.配置跨域
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.setAllowCredentials(true);
source.registerCorsConfiguration("/**",corsConfiguration);
return new CorsWebFilter(source);
}
}