SpringBoot 解决前端全局跨域请求
/***
* 解决前端请求跨域问题
*/
@Configuration
public class MVCconfiguration implements WebMvcConfigurer {
// 解决前端请求跨域问题
@Override
public void addCorsMappings(CorsRegistry registry) {
// WebMvcConfigurer.super.addCorsMappings(registry);
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowedMethods("GET","HEAD","POST","DELETE")
.maxAge(3600)// 预检间隔时间
.allowedHeaders("*");// 允许协议头
}
}