on 2025 Feb 06 3:46 PM
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();
Request clarification before answering.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
64 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.