I would like to know what is the best way fetch a resource from our client's site to our servers with the Fetch API (GET). In order to do so we need to send the current URL since the resource depends on that.
We've come up with two choices so far:
- Sending the current URL encoded with
encodeURIComponent
as part of the query string. Could be also base64 if it is safer. In this case, which is the best function that is PHP compatible for decoding? - Using the
referer
header of the HTTP Request. We found out that this works without additional effort but the default value for this is not consistent among browsers due to privacy concerns [1]. We could try to force the referrer Policy tono-referrer-when-downgrade
for this particular request but in doing so we wouldn't want to hurt the user's privacy.
Thanks