cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <>
Subject Re: UriInfo.getRequestUri().getHost() returns 'localhost' instead of ''
Date Mon, 02 Nov 2015 20:59:24 GMT

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 - 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

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 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 '' to have 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
> '' when requests are made to
> The scenario is as follows:
> * A users accesses the application via
> * 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
> * 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 and not localhost
> Similar behavior occurs when accessing the application via
> 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
> Thanks!
> -Jesse

View raw message