I am trying to retrieve the IP address which makes the call to a REST call.
The code I have is:
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import org.json.JSONObject;
@Path("/api")
public class Endpoints {
@GET
@Path("/whoami")
@Produces(MediaType.APPLICATION_JSON)
public String testHeaders(@Context final HttpServletRequest request){
final JSONObject json = new JSONObject();
json.put("remoteaddr", request.getRemoteAddr());
return json.toString(4);
}
}
the application is deployed on heroku here. When you make the call to the api it returns the ip is: 10.155.0.152
, how ever when I google it it says my IP address is something different. Is there any way to return the actual IP?