|
|
@@ -5,9 +5,29 @@ spring:
|
|
5
|
5
|
name: gateWay-server
|
|
6
|
6
|
profiles:
|
|
7
|
7
|
active: dev
|
|
8
|
|
-
|
|
9
|
|
-
|
|
10
|
|
-
|
|
|
8
|
+# cloud: # <--- 添加或合并到现有的 spring.cloud 块下
|
|
|
9
|
+# gateway:
|
|
|
10
|
+# globalcors: # <--- 全局 CORS 配置
|
|
|
11
|
+# cors-configurations:
|
|
|
12
|
+# '[/**]': # <--- 对所有路径 (/**) 应用此 CORS 配置
|
|
|
13
|
+# # -- 重要:修改为你本地运行的前端地址和端口 --
|
|
|
14
|
+# # allowedOrigins: "http://localhost:8080" # 如果只允许单个精确源
|
|
|
15
|
+# allowedOriginPatterns: # 更推荐,允许 localhost 的任意端口
|
|
|
16
|
+# - "*"
|
|
|
17
|
+# # --↑↑↑ 根据你前端实际情况修改 ↑↑↑--
|
|
|
18
|
+#
|
|
|
19
|
+# allowedMethods: # 允许的 HTTP 方法
|
|
|
20
|
+# - "GET"
|
|
|
21
|
+# - "POST"
|
|
|
22
|
+# - "PUT"
|
|
|
23
|
+# - "DELETE"
|
|
|
24
|
+# - "OPTIONS" # OPTIONS 很重要,用于预检请求
|
|
|
25
|
+# allowedHeaders: "*" # 允许所有请求头
|
|
|
26
|
+# allowCredentials: true # 允许发送 Cookie 等凭证
|
|
|
27
|
+# maxAge: 360000 # 预检请求 (OPTIONS) 的缓存时间 (毫秒)
|
|
|
28
|
+#
|
|
|
29
|
+## 如果你的 Gateway 也使用了 Spring Security, 你可能还需要在Security配置中处理CORS
|
|
|
30
|
+## (见上一个回答中的 Spring Security 配置示例),并且要放行 OPTIONS 请求。
|
|
11
|
31
|
|
|
12
|
32
|
logging:
|
|
13
|
33
|
config: classpath:log4j2.xml
|