|
@@ -10,12 +10,15 @@ public class MyWebConfigurer implements WebMvcConfigurer {
|
|
@Override
|
|
@Override
|
|
public void addCorsMappings(CorsRegistry registry) {
|
|
public void addCorsMappings(CorsRegistry registry) {
|
|
// 设置允许跨域的路径
|
|
// 设置允许跨域的路径
|
|
|
|
+ /**
|
|
|
|
+ * 所有请求都允许跨域,使用这种配置就不需要
|
|
|
|
+ * 在interceptor中配置header了
|
|
|
|
+ */
|
|
registry.addMapping("/**")
|
|
registry.addMapping("/**")
|
|
- // 设置允许跨域请求的域名
|
|
|
|
- .allowedOrigins("*")
|
|
|
|
- // 是否允许证书
|
|
|
|
.allowCredentials(true)
|
|
.allowCredentials(true)
|
|
- .allowedMethods("*")
|
|
|
|
|
|
+ .allowedOrigins("*")
|
|
|
|
+ .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
|
|
|
|
+ .allowedHeaders("*")
|
|
.maxAge(3600);
|
|
.maxAge(3600);
|
|
}
|
|
}
|
|
|
|
|