How to preserve referrer (Referer HTTP header) across subdomains?

2.2k Views Asked by At

I have a website running on www.example.com that makes GET requests to api.example.com to process a form. When I examine web server logs for api.example.com I see that requests from Safari get the full referer (e.g., www.example.com/page-where-request-originated). But requests from Chrome only get a partial referer (www.example.com).

I need the ability to track the full referring page when the request hits api.example.com. Reviewing the documentation for Referrer-Policy it seems my only option is to set it to unsafe-url. But that seems overkill because I only want the referrer to be sent for subdomains of example.com. Is that possible?

1

There are 1 best solutions below

0
On

The only option I can find is strict-origin : Send the origin as referrer, but only when the request is no downgrade from https to http.

see: https://wiki.crashtest-security.com/enable-security-headers

Everything else will either omit the referrer completely or send the origin URL without any URL parameters.