From f8a73ae78727eab0063a26b4c57c3d451f1a0ab5 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期四, 18 四月 2024 14:23:05 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes
---
hangzhoumesParent/gateway/src/main/java/com/mes/config/MyCorsConfig.java | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/hangzhoumesParent/gateway/src/main/java/com/mes/config/MyCorsConfig.java b/hangzhoumesParent/gateway/src/main/java/com/mes/config/MyCorsConfig.java
new file mode 100644
index 0000000..f7f9f8d
--- /dev/null
+++ b/hangzhoumesParent/gateway/src/main/java/com/mes/config/MyCorsConfig.java
@@ -0,0 +1,34 @@
+package com.mes.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.reactive.CorsWebFilter;
+import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
+
+/**
+ * @Author : zhoush
+ * @Date: 2024/3/25 14:13
+ * @Description:
+ */
+@Configuration
+public class MyCorsConfig {
+ @Bean
+ public CorsWebFilter corsFilter() {
+
+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+ CorsConfiguration corsConfiguration = new CorsConfiguration();
+ //鍏佽鍝簺澶磋法鍩�
+ corsConfiguration.addAllowedHeader("*");
+ // 鍏佽鍝簺鏂瑰紡璺ㄥ煙 get post delete 绛夋柟寮�
+ corsConfiguration.addAllowedMethod("*");
+ //鍏佽鍝簺璇锋眰鏉ユ簮璺ㄥ煙 * 浠绘剰鏉ユ簮
+ corsConfiguration.addAllowedOrigin("*");
+ // 鏄惁鍏佽鎼哄甫cooker璺ㄥ煙
+ corsConfiguration.setAllowCredentials(true);
+ //娉ㄥ唽璺ㄨ秺閰嶇疆 /**閰嶇疆璇锋眰璺緞
+ source.registerCorsConfiguration("/**", corsConfiguration);
+ return new CorsWebFilter(source);
+ }
+
+}
--
Gitblit v1.8.0