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);
}
}