2

I am trying to create a gateway+microservice setup (using jhipster 7.8.1) something similar to this sample but without eureka service discovery.

After generation, the applications boots fine but the UI (in my case Angular) is unable to reach the microservice (i.e unable to perform CRUD operation - I see 404 in the gateway). I did some initial digging and found the following in application.yml in gateway app

spring:
  application:
    name: gateway
  cloud:
    gateway:
      default-filters:
        - JWTRelay
      discovery:
        locator:
          enabled: true
          lower-case-service-id: true
          predicates:
            - name: Path
              args:
                pattern: "'/services/'+serviceId.toLowerCase()+'/**'"
          filters:
            - name: RewritePath
              args:
                regexp: "'/services/' + serviceId.toLowerCase() + '/(?<remaining>.*)'"
                replacement: "'/${remaining}'"

which seems to be doing the routing, especially

spring.cloud.gateway.discovery.locator.enabled:true

seems to be doing the magic of mapping the apps registered with the discovery service to be available for gateway proxy'ing (reference)

I looked into the template in the jhipster's code base and did not find any other implementation for the no discovery service option.

For the no discovery service option I was expecting to see (with my limited knowledge of gateway) some explicit route mapping in the gateway to my microservices. Am i missing something or do I have to tweak something in the gateway to make it work without the discovery service.

Any help is greatly appreciated...

Note: I was able to run my setup as expected with eureka discovery (jhipster registry)

Dwaraka
  • 179
  • 8
  • 1
    You are expected to manually create your static routes for your services (https://cloud.spring.io/spring-cloud-gateway/reference/html/#route-metadata-configuration), the generator won't help here. It could do it in the case you generated your gateway and services within one JDL (see https://www.jhipster.tech/jdl/applications#more-than-one-application) but that's a specific case, this is probably why it's not implemented. – Gaël Marziou Jul 14 '22 at 07:58
  • 1
    Thank you for your response, I did create the applications using the sample JDL but the static routes were not created and that's why I went to the application.yml template in gateway to confirm that there is a static route option, but there wasn't. I will modify the gateway and make it work. Once again thank you! – Dwaraka Jul 14 '22 at 13:27

0 Answers0