SpringBoot配置解决跨域

@Configuration
public class MvcConfig implements WebMvcConfigurer {


     @Override
     public void addCorsMappings(CorsRegistry registry) {
         registry.addMapping("/**")
                 .allowedOriginPatterns("*")
                 .allowedMethods("POST", "GET")
                 .maxAge(3600)
                 .allowCredentials(true);
    }


}
学习时的痛苦是暂时的 未学到的痛苦是终生的
本文版权归作者和博客园共有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/juanxincai/p/15592157.html