跨域

spring

配置全局

点击查看代码

/**
 * 配置全局跨域
 * @author Leonan
 * @date 2020/5/21 22:08
 */
@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {
    static final String[] ORIGINS = new String[] { "GET", "POST", "PUT", "DELETE" };

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

}

posted @ 2022-12-26 19:29  jf666new  阅读(11)  评论(0)    收藏  举报