我只有这条路
spring.cloud.gateway.routes[0].id=x-service
spring.cloud.gateway.routes[0].uri=http://localhost:5555/x-service/v1/private/files
spring.cloud.gateway.routes[0].predicates[0]=Path=/v1/private/files但是应用程序重定向到/v1/private/files。
怎么解决这个问题?
发布于 2022-08-16 15:09:18
AFAIK春季云网关Route构建器只考虑主机名和传递给UriSpec.uri(String uri)的端口,因此此时只有http://localhost:5555起作用。
因此,您需要使用网关筛选器重写路径,如下所示:
spring.cloud.gateway.routes[0].filters[0]=RewritePath=/v1/private/files, /x-service/v1/private/files第一个论点是最初的路径,其次是一个替代者。
RegEx也可以在那里使用。
有关详细信息,请查看spring云网关参考文档。
此外,我建议阅读这篇文章。
https://stackoverflow.com/questions/73374509
复制相似问题