Search code examples
javaspringspring-bootspring-cloud-gateway

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 ?


Solution

  • 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}