【问题标题】:How to add a /api/v1/ prefix to uri in spring cloud gateway?如何在 Spring Cloud Gateway 中为 uri 添加 /api/v1/ 前缀?
【发布时间】:2022-01-11 10:43:07
【问题描述】:

我有两个服务和一个使用 eureka 的网关:
在 8081 上运行的用户服务
在 8082 上运行的健康服务
到目前为止,我试过这个:

routes:
        - id: user-service-route
          uri: http://localhost:8081/user-service
          predicates:
            - Path=/user-service/**
          filters:
            - RewritePath=(?<serviceName>.*), /api/v1/{serviceName}

但它不起作用。

【问题讨论】:

    标签: regex spring spring-cloud-gateway


    【解决方案1】:

    试试

    filters:
            - RewritePath=(?<serviceName>.*), /api/v1/$\{serviceName}
    

    【讨论】:

      猜你喜欢
      • 2020-02-24
      • 2019-05-04
      • 2020-01-14
      • 2014-09-29
      • 2023-02-18
      • 1970-01-01
      • 2023-04-02
      • 2019-06-03
      • 2018-12-05
      相关资源
      最近更新 更多