一、報(bào)錯內(nèi)容如下:
Failed to load http://192.168.1.111:8888/console/good/front/classList: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8081’ is therefore not allowed access. If an opaque response serves your needs
二、在后臺添加如下文件

@Configuration
public class MvcConfigimplements WebMvcConfigurer {
@Override
? ? public void addCorsMappings(CorsRegistry registry) {
// 這里匹配了所有的URL,允許所有的外域發(fā)起跨域請求,允許外域發(fā)起請求任意HTTP Method,允許跨域請求包含任意的頭信息。
? ? ? ? registry.addMapping("/**")
.allowedHeaders("*")
.allowedMethods("*")
.allowedOrigins("*")
.allowCredentials(true);
}
}
即可解決,當(dāng)然也可以在nginx設(shè)置