SpringBoot配置解决跨域

@Configuration
public class MvcConfig implements WebMvcConfigurer {


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


}

 

posted @ 2021-11-23 10:45  卷心菜的奇妙历险  阅读(51)  评论(0编辑  收藏  举报