I have a public php site. It features JSON webservices, which I use for jQuery autocomplete. The web site is public, so are the webservices.
However, I want to restrict the webservices so they can only be called from the corresponding website (ie HTML pages loaded from that web site).
What would be a good solution for that?
Restriction in this context means:
My webservice (e.g. fooservice.php
) is public. As the user is not authenticated I wonder how I can check if it is called from a page of my site (e.g. mypagewithautocomplete.php
)
https://stackoverflow.com/a/38614140/356726 is a useful answer (+1), but only avoids AJAX usage from another browser. It does not prevent just reading the JSON result in the browser.