简体   繁体   中英

Spring cloud gateway 2.5 with eureka return 404

I'm trying to build a gateway with load balancer by using spring-cloud-gateway But when I hit gateway, it gives me 404 instead of routing me to the registered service in eureka

I don't want to use auto-discover feature, so I use manual routing instead.

my code is uploaded here : https://github.com/gry77/poc-spring-cloud-gateway

How can I fix it ?

Got answer from github, I must include ReWritePath to get it works

spring:
  application:
    name: api-gateway
  cloud:
    gateway:
      discovery:
        locator:
          lower-case-service-id: true
          enabled: false
      routes:
        - id: my-service
          uri: lb://my-service
          predicates:
            - Path=/service/**
          filters:
            - RewritePath=/service(?<segment>/?.*), /${segment}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM