From dbe3740fba28955b8134839c294cbe3e2ed8def4 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期日, 14 四月 2024 17:06:59 +0800
Subject: [PATCH] 初次提交权限相关功能

---
 hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/InterceptorConfig.java |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/InterceptorConfig.java b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/InterceptorConfig.java
index 39ffa21..a5ad9af 100644
--- a/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/InterceptorConfig.java
+++ b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/InterceptorConfig.java
@@ -2,16 +2,17 @@
 
 import com.mes.common.interceptor.JwtInterceptor;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
 import javax.annotation.Resource;
 
 @Configuration
-
 public class InterceptorConfig implements WebMvcConfigurer {
     @Resource
     private JwtInterceptor jwtInterceptor;
+
     @Override
     public void addInterceptors(InterceptorRegistry registry) {
         registry.addInterceptor(jwtInterceptor)
@@ -19,11 +20,26 @@
                 .excludePathPatterns("/user/login",
                         "/user/register",
                         "/swagger-resources/**"
-                        ,"/webjars/**"
-                        ,"/v2/**"
-                        ,"/swagger-ui.html/**"
-                        ,"/swagger-ui.html#/**");
+                        , "/webjars/**"
+                        , "/v2/**"
+                        , "/swagger-ui.html/**"
+                        , "/swagger-ui.html#/**");
     }
 
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        // 璁剧疆鍏佽璺ㄥ煙鐨勮矾寰�
+        registry.addMapping("/**")
+                // 璁剧疆鍏佽璺ㄥ煙璇锋眰鐨勫煙鍚�
+//                .allowedOriginPatterns("*")
+                // 鏄惁鍏佽cookie
+                .allowCredentials(true)
+                // 璁剧疆鍏佽鐨勮姹傛柟寮�
+                .allowedMethods("GET", "POST", "DELETE", "PUT")
+                // 璁剧疆鍏佽鐨刪eader灞炴��
+                .allowedHeaders("*")
+                // 璺ㄥ煙鍏佽鏃堕棿
+                .maxAge(3600);
+    }
 
 }

--
Gitblit v1.8.0