I have some REST API's deployed on api.xyz.com now I wants to allow all API's accessible through Authorized mobile devices and My domain only xyz.com.
If i set allow origin headers to my site then API stops responding to Mobile devices.Please suggest if its possible.
Also when I try to get consumer IP address in REST API call then it always return my API server public IP in $_SERVER[REMOTE_ADDR] instead of client IP address.I also tried to get consumer IP address but no success.
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP')) {
$ipaddress = getenv('HTTP_CLIENT_IP');
} else if (getenv('HTTP_X_FORWARDED_FOR')) {
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
if (strpos($ipaddress, ',') > 0) {
$addr = explode(",", $ipaddress);
$ipaddress = trim($addr[0]);
}
} else if (getenv('HTTP_X_FORWARDED')) {
$ipaddress = getenv('HTTP_X_FORWARDED');
} else if (getenv('HTTP_FORWARDED_FOR')) {
$ipaddress = getenv('HTTP_FORWARDED_FOR');
} else if (getenv('HTTP_FORWARDED')) {
$ipaddress = getenv('HTTP_FORWARDED');
} else if (getenv('REMOTE_ADDR')) {
$ipaddress = getenv('REMOTE_ADDR');
} else {
$ipaddress = 'UNKNOWN';
}
Please suggest why it always give my server public IP even IF i hit api through my machine.
Thanks