From e208aa1ef8e861dba168e8d83ab3066fc9f1e02d Mon Sep 17 00:00:00 2001
From: 严智鑫 <test>
Date: 星期二, 16 四月 2024 13:30:45 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes
---
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