I'm so new to headers. So, this is what I came out with to read the client's IP for WordPress custom REST API.
if ( !empty( $request->get_header('X-Forwarded-For') ) ) {
$merchant_ip = $request->get_header('X-Forwarded-For');
} elseif (!empty( $request->get_header('Remote_Addr') )) {
$merchant_ip = $request->get_header('Remote_Addr');
} else {
$merchant_ip = $request->get_header('X-Client-IP');
}
Did I miss out any other headers? Or do you think there's a better way to read the IP.