浏览代码

解开跨域配置

yq 4 年之前
父节点
当前提交
364f1e2a85
共有 1 个文件被更改,包括 25 次插入25 次删除
  1. 25 25
      fiveep-service/src/main/java/com/bizmatics/service/config/MyWebConfigurer.java

+ 25 - 25
fiveep-service/src/main/java/com/bizmatics/service/config/MyWebConfigurer.java

@@ -1,25 +1,25 @@
-//package com.bizmatics.service.config;
-//
-//import org.springframework.boot.SpringBootConfiguration;
-//import org.springframework.web.servlet.config.annotation.CorsRegistry;
-//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-//
-//@SpringBootConfiguration
-//public class MyWebConfigurer implements WebMvcConfigurer {
-//
-//    @Override
-//    public void addCorsMappings(CorsRegistry registry) {
-//        // 设置允许跨域的路径
-//        /**
-//         * 所有请求都允许跨域,使用这种配置就不需要
-//         * 在interceptor中配置header了
-//         */
-//        registry.addMapping("/**")
-//                .allowCredentials(true)
-//                .allowedOrigins("*")
-//                .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
-//                .allowedHeaders("*")
-//                .maxAge(3600);
-//    }
-//
-//}
+package com.bizmatics.service.config;
+
+import org.springframework.boot.SpringBootConfiguration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@SpringBootConfiguration
+public class MyWebConfigurer implements WebMvcConfigurer {
+
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        // 设置允许跨域的路径
+        /**
+         * 所有请求都允许跨域,使用这种配置就不需要
+         * 在interceptor中配置header了
+         */
+        registry.addMapping("/**")
+                .allowCredentials(true)
+                .allowedOrigins("*")
+                .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
+                .allowedHeaders("*")
+                .maxAge(3600);
+    }
+
+}