From 45de8e0e5e7b9aef238feefb2750bd776f116f40 Mon Sep 17 00:00:00 2001 From: wulin Date: Sat, 29 Mar 2025 19:18:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BD=91=E5=85=B3=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/bootstrap-dev.yml | 6 ++-- .../src/main/resources/bootstrap-online.yml | 30 +++++++++++++++++++ api-gateway/src/main/resources/bootstrap.yml | 2 +- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/api-gateway/src/main/resources/bootstrap-dev.yml b/api-gateway/src/main/resources/bootstrap-dev.yml index 539ce7c..5c0793c 100644 --- a/api-gateway/src/main/resources/bootstrap-dev.yml +++ b/api-gateway/src/main/resources/bootstrap-dev.yml @@ -5,10 +5,10 @@ spring: - 192.168 #注册到nacos中心优先匹配的IP gateway: routes: - - id: heyu-api-user-api - uri: lb://heyu-api-user-api + - id: api-interface + uri: lb://api-interface predicates: - - Path=/api-user/** + - Path=/api-interface/** filters: # 转发时去掉一层路径 - StripPrefix=1 diff --git a/api-gateway/src/main/resources/bootstrap-online.yml b/api-gateway/src/main/resources/bootstrap-online.yml index c508d58..e774819 100644 --- a/api-gateway/src/main/resources/bootstrap-online.yml +++ b/api-gateway/src/main/resources/bootstrap-online.yml @@ -16,3 +16,33 @@ spring: # 共享配置 #shared-configs: # - application.${spring.cloud.nacos.config.file-extension} + inetutils: + preferredNetworks: + - 192.168 #注册到nacos中心优先匹配的IP + gateway: + routes: + - id: api-interface + uri: lb://api-interface + predicates: + - Path=/api-interface/** + filters: + # 转发时去掉一层路径 + - StripPrefix=1 + - id: heyu-api-websocket + uri: lb://heyu-api-websocket + predicates: + - Path=/api-websocket/** + filters: + # 转发时去掉一层路径 + - StripPrefix=1 + globalcors: + corsConfigurations: + '[/**]': + # 允许携带认证信息 + allow-credentials: true + # 允许跨域的源(网站域名/ip),设置*为全部 + allowedOriginPatterns: "*" + # 允许跨域的method, 默认为GET和OPTIONS,设置*为全部 + allowedMethods: "*" + # 允许跨域请求里的head字段,设置*为全部 + allowedHeaders: "*" \ No newline at end of file diff --git a/api-gateway/src/main/resources/bootstrap.yml b/api-gateway/src/main/resources/bootstrap.yml index 8c6b851..abed308 100644 --- a/api-gateway/src/main/resources/bootstrap.yml +++ b/api-gateway/src/main/resources/bootstrap.yml @@ -2,7 +2,7 @@ server: port: 8080 spring: application: - name: heyu-api-gateway + name: api-gateway profiles: active: dev main: