在application.yml中:
spring:
cloud:
nacos:
server-addr: localhost:8848
gateway:
routes:
- id: user # 路由唯一标识
uri: lb://user-service # 目标地址,lb:// 代表负载均衡(从注册中心获取服务)
predicates:
- Path=/user/** # 断言规则:匹配路径以/user开头的请求
filters:
- StripPrefix=1 # 去除n层前缀,如/api/user/**变为/user/**