







实现WebMvcConfigurer接口
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry
// 允许跨域访问的路径
.addMapping("/**")
// 允许跨域访问的源
.allowedOrigins("*")
// 允许请求的方法
.allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
// 允许发送 cookie
.allowCredentials(true)
// 预检间隔时间
.maxAge(3600)
// 允许的 Header
.allowedHeaders("*");
WebMvcConfigurer.super.addCorsMappings(registry);
}
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。