cancel
Showing results for 
Search instead for 
Did you mean: 

How to get ClientIP in Sap commerce cloud Backend.

ABasak
Discoverer
0 Kudos
164

How to capture the client api from Sap commerce Cloud Backend api.

Currenly i am using the below code

In this getHeader("X-FORWARDED-FOR") is giving null and  using the getRemoteAddr api sometimes we are getting correct details.Is there any way we can capture it properly

String forwardedClientIp = servletRequest.getHeader("X-FORWARDED-FOR");
String clientIp = StringUtils.isNotEmpty(forwardedClientIp) ? forwardedClientIp : servletRequest.getRemoteAddr();
View Entire Topic
cieslo
Product and Topic Expert
Product and Topic Expert
0 Kudos

Client IP address can be recorded in different headers (depending if the CDN was used or not and wich CDN). As you mentioned it could be "X-FORWARDED-FOR". For Akamai you could extract it from "True-Client-IP" header. Checking the ones from "X-FORWARDED-FOR" or "True-Client-IP" before actually using remote address from the request seems like a good approach.

ABasak
Discoverer
0 Kudos
Hi Cieslo, Thanks for your response. We are not using any cdn currently.Requests are directly getting handled through CCV2.So which parameter should i refer in that case