I have deployed my REST API into different domain. So from frontend when API is called I need to get the browser URL.
Lets say, API is https://api.xxx.xxx
and I am calling from https://www.123.co
.
I have tried following lines, but it gives me only https://api.xxx.xxx
while I need https://www.123.co
$link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";