I have a spring boot 2.0.2 web application behind a zuul gateway. My application uses spring hateoas links. Also my application has context-path set lets say xxx.
When queries are made through zuul gateway, hateoas links become invalid. Reason is the following: Lets say a make a call https://localhost/serviceName/service-context-path/path. I would require my heteoas links become i.e. https://localhost/serviceName/service-context-path/path/ however, these links become: https://localhost/service-context-path/path/.
Ihave made search and found in stack overflow this link (HATEOAS paths are invalid when using an API Gateway in a Spring Boot app) Indeed, add-proxy-headers by default true sends X-FORWARDED-PREFIX (allong host, etc) which i guess it was communitys intention to fix this problem. But... when i debug my application i reached this method org.springframework.web.servlet.support.ServletUriComponentsBuilder#fromContextPath, with java doc part the following: As of 4.3.15, this method replaces the contextPath with the value "X-Forwarded-Prefix" rather than prepending, thus aligning with {@code ForwardedHeaderFiller}.
This means the following, when X-FORWARDED-PREFIX is present, application context is replaced from the zuul's prefix which is the serviceName. I guess uul developers on their side cannot know the application context and on the other side, org.springframework.web.servlet.support.ServletUriComponentsBuilder#fromContextPath is compatible with the corresponding specification.
Question: How do i proceed? i for sure wish my hateoas links to be correct when i use zuul
My quess is that there is no solution here. Proper way is to avoid usage of zuul and move to Spring cloud gateway.