问题
I'm proxying a Spring REST backend like so:
Backend:
http://backend:8080
Proxied localhost:
localhost:3000/api/backend -> http://backend:8080
If I browse locally to a proxied endpoint, it will proxy the request, the links, however, do not include the proxy path, i.e.
GET localhost:3000/api/backend/people
"href": "http://localhost:3000/people"
I would expect this to be:
"href": "http://localhost:3000/api/backend/people"
There any way to fix this?
Thanks!
回答1:
You should have a look at the x-forwarded-*
headers your proxy is adding to the request.
If the request from your proxy to the backend contains the header x-forwarded-prefix=/api/backend
spring will pick up the prefix and add it to the generated link.
You do not mention which proxy are you using so I cannot tell if your proxy supports adding the x-forwarded-prefix
header.
来源:https://stackoverflow.com/questions/36141608/spring-data-rest-proxy-path-not-including-link-path