'访问图像'http://106.52.144.80:8886/zhfile/162329374589118053.png“从原点”http://live.taappo.com:8082“已被CORS策略阻止:请求的资源上不存在“Access Control Allow Origin”标头。
添加一个配置类,如下:
public class WebMvcConfig implements WebMvcConfigurer{
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://live.taappo.com:8082")
.allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE","OPTIONS")
.allowedHeaders("Origin", "X-Requested-With", "Content-Type", "token", "Accept","Access-Control-Request-Method", "Access-Control-Request-Headers")
.exposedHeaders("Access-Control-Allow-Origin", "Access-Control-Allow-Credentials")
.allowCredentials(true)
.maxAge(3600);
}
}
123456