美文网首页
跨域问题

跨域问题

作者: lizg | 来源:发表于2021-04-26 16:44 被阅读0次
    import org.springframework.web.servlet.config.annotation.CorsRegistry;
    import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
    
    @Configuration
    public class CrosConfig implements WebMvcConfigurer {
        @Override
        public void addCorsMappings(CorsRegistry registry) {
            registry.addMapping("/**")
                    .allowedOriginPatterns("*")
                    .allowedMethods("GET","HEAD","POST","PUT","DELETE","OPTIONS")
                    .allowCredentials(true)
                    .maxAge(3600)
                    .allowedHeaders("*");
        }
    }
    

    相关文章

      网友评论

          本文标题:跨域问题

          本文链接:https://www.haomeiwen.com/subject/uouerltx.html