I have below piece of code to rewrite the path while routing the request to correct endpoint. However still the routing happening with full URL (original) without rewriting URL. Similar type of path rewrite has been used for another endpoint, which is working fine.
Code:
@Override
public Route.AsyncBuilder apply(PredicateSpec route) {
return route
.path("/api/out/**")
.filters(f -> f
.removeRequestHeader("Cookie")
.filter(loggingGatewayFilter)
.filter(oauth2GatewayFilter)
.filter(this::filter)
.rewritePath("/api/out", "")
)
.uri(uri);
}
original URL: http://external-url/api/out/xyz/data/getNext
expected outcome: URL path will be rewritten to http://external-url/xyz/data/getNext
But still router is invoking the full URL.
What could be the issue here? Any configuration in server side/endpoint (http://external-url) could cause this issue?
Spring cloud debug logs.
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 47 45 54 20 2f 76 31 2f 6f 6d 73 2f 74 72 61 6e |GET /xyz/data/get|
|00000010| 63 68 65 73 3f 70 61 67 65 3d 30 26 73 69 7a 65 |Next?page=0&size|
|00000020| 3d 31 30 30 26 63 72 65 61 74 65 64 42 65 66 6f |=100&createdBefo|
|00000030| 72 65 3d 32 30 32 31 2d 30 31 2d 32 39 54 32 33 |re=2021-01-29T23|
|00000040| 25 33 41 35 39 25 33 41 35 39 2e 39 39 39 25 32 |%3A59%3A59.999%2|
|00000050| 42 30 38 25 33 41 30 30 26 63 72 65 61 74 65 64 |B08%3A00&created|
|00000060| 41 66 74 65 72 3d 32 30 32 31 2d 30 31 2d 32 39 |After=2021-01-29|