修改网关配置

This commit is contained in:
wulin 2025-03-29 19:18:41 +08:00
parent e22e597497
commit 45de8e0e5e
3 changed files with 34 additions and 4 deletions

View File

@ -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

View File

@ -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: "*"

View File

@ -2,7 +2,7 @@ server:
port: 8080
spring:
application:
name: heyu-api-gateway
name: api-gateway
profiles:
active: dev
main: