Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Data Rest - Proxy path not including link path

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!

like image 326
dardo Avatar asked Mar 21 '16 21:03

dardo


1 Answers

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.

like image 174
Mathias Dpunkt Avatar answered Oct 06 '22 23:10

Mathias Dpunkt