Hi

Does JAX-RS endpoint have an absolute URI address at the initialization time, if so how does it look like ? In HttpUtils.toAbsoluteUri there's a line which defaults to 'localhost' if it its 127.0.0.1 - I don't recall right now why but I vaguely remember I did it in order to address some issue of its own related to the use of 127.0.0.1.

Do you see that line being exercised, if yes I can introduce a property, something like 'preserve.local.ip.address' as a short term workaround. Though if you say using 0.0.0.0 also leads to a 'localhost' being reported then it is coming out of non-CXF code (request.getLocalAddress()) - I'm honestly not sure what can be done in case of '0.0.0.0' to have 127.0.0.1 reported instead...

Cheers, Sergey

On 02/11/15 18:02, Jesse White wrote:
Hi,

We're we're using CXF v3.1.3 via JAX-RS and we noticed that
UriInfo.getRequestUri().getHost() is returning 'localhost' instead of
'127.0.0.1' when requests are made to http://127.0.0.1.

The scenario is as follows:
* A users accesses the application via http://127.0.0.1
* The user logs in, creating a session cookie
* The user takes a action on the page that triggers a request to our
ReST API at http://127.0.0.1/rest
* The call in question returns a 303 See Other response with a Location
header of http://localhost/rest
* The user gets a 401 Unauthorized since his session cookie is
associated with 127.0.0.1 and not localhost

Similar behavior occurs when accessing the application via http://0.0.0.0.

I've tracked down the code that does replacement to:
     org.apache.cxf.jaxrs.utils.HttpUtils#toAbsoluteUri(URI u, Message
message)

Is there any way to change this behavior? I would expect the same host
to be returned even when making calls to 127.0.0.1.

Thanks!

-Jesse


Reply via email to