We have REST API that we want only our domain has access to and that spoofed requests are not sent. To do so, the only thing coming in my mind was checking the referer $_SERVER['HTTP_REFERER']
. However the docs say that:
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
So let's say our main API requests/gate file is:
www.example.com/api/gate.php
How do I make it secure so that only requests from own domain are served and all other disregarded. I have read a little about http authentication and seting up private keys or secret but I am looking for a simple way so only our own domain can send requests to that file. Thanks