1

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]";
S S
  • 1,443
  • 2
  • 12
  • 42
  • 1
    Not sure I understand, do you mean that you want to retrieve the Referral page? So not the page of the API but the page in your frontend that called the API? If so you need to use `$_SERVER["HTTP_REFERER"];` – Andrea Olivato Jul 19 '21 at 05:00
  • 2
    @SS Just so you know, HTTP referers aren't reliable. https://stackoverflow.com/questions/6023941/how-reliable-is-http-referer – nice_dev Jul 19 '21 at 05:12

0 Answers0