0

Consider a request "http://localhost:gatewayport/myapp" where I want to redirect the request to "http://localhost:appport/" This works ok except that the images, styles hosted on myapp are requested as "http://localhost:gatewayport/image.gif" (without the "/myapp") context and hence they don't load. Tried adding redirect filter (302) by redirecting to /myapp/ but that goes in a loop

routeBuilder.route(
    p ->
    p.path("/myapp")
    .filters(
         f ->
        f.redirect(302, "/myapp/"))  
        .uri("lb://gatewayserver"));
              
Manisha
  • 91
  • 4

1 Answers1

0

The loop was because the consequent request (/myapp/) was also matching the pattern "/myapp".

The following worked fine

//redirect back to gateway 
routeBuilder.route(
    p ->
    p.path(false,"/myapp") // false indicates DO_NOT_MATCH trailing slash
    .filters(
            f ->
            f.redirect(302, "/myapp/")) 
    .uri(GATEWAYSERVER));

//this will forward to actual server
routeBuilder.route(
    p ->
    p.path("/myapp/", "/myapp/**")
    .filters(
            f ->
            f.stripPrefix(1))
    .uri(targetURI));
Manisha
  • 91
  • 4