我的配置如下:
routes:
- id: provider-base
uri: http://localhost:7001/
predicates:
- Path=/api/**
现在是想通过访问 网关host/api/test 来访问到 http://localhost:7001/test,现在的配置无法实现,无论怎么请求,都被转发到了http://localhost:7001/,请教各路大神应该如何配置。
我的配置如下:
routes:
- id: provider-base
uri: http://localhost:7001/
predicates:
- Path=/api/**
现在是想通过访问 网关host/api/test 来访问到 http://localhost:7001/test,现在的配置无法实现,无论怎么请求,都被转发到了http://localhost:7001/,请教各路大神应该如何配置。
添加 RewritePath
filter, 将 /api
重写为 /
routes:
- id: provider-base
uri: http://localhost:7001/
predicates:
- Path=/api/**
filters:
- RewritePath=/api, /
看您配置的这里累,建议你直接替换spring-cloud-gateway为fizz-gateway,都是基于webflux,性能还比spring-cloud-gateway要好,自带后台配置界面,热更新,无需重启。也不用编码了。
spring:
cloud: