首页 > 解决方案 > 如何跨子域保留引荐来源网址(Referer HTTP 标头)?

问题描述

我有一个网站正在运行,www.example.com它发出 GET 请求api.example.com来处理表单。当我检查网络服务器日志时,api.example.com我看到来自 Safari 的请求获得了完整的引用(例如www.example.com/page-where-request-originated)。但是来自 Chrome 的请求只能获得部分引用(www.example.com)。

当请求命中时,我需要能够跟踪完整的引用页面api.example.com。查看Referrer-Policy 的文档,似乎我唯一的选择是将其设置为unsafe-url. 但这似乎有点过头了,因为我只希望为example.com. 那可能吗?

标签: cross-domainreferrerreferrer-policy

解决方案


我能找到的唯一选择是strict-originSend the origin as referrer, but only when the request is no downgrade from https to http

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

其他所有内容要么完全省略引荐来源网址,要么发送不带任何 URL 参数的原始 URL。


推荐阅读