-
Notifications
You must be signed in to change notification settings - Fork 6
浏览器的 Referrer-Policy #98
Copy link
Copy link
Closed
Labels
HTTPWhere everything flowsWhere everything flows
Description
问题起因
最近在测试后端 API 时,发现在不同的设备、浏览器上请求同一个 API 时,后端收到的 Referer 是不同的。于是 Google 了一番,发现原来是不同的浏览器设置了不同的 Referrer-Policy。
目前各浏览器 Referrer-Policy 设置
| 浏览器 | 版本 | 设置 |
|---|---|---|
| Chrome | 85 | strict-origin-when-cross-origin |
| Firefox | 81 | no-referrer-when-downgrade |
| Edge | 86 | strict-origin-when-cross-origin |
未来趋势
为了加强隐私安全,预计各浏览器最终都会将 Referrer-Policy 设置为 strict-origin-when-cross-origin。
Referrer-Policy 字段值含义
strict-origin-when-cross-origin:如果跨域,则Referer字段值为Origin的值;如果没有跨域,则Referer字段值为完整 URL。no-referrer-when-downgrade:如果是从 HTTPS 向 HTTP 发起请求,则Referer字段值为Origin的值,否则为完整 URL。
知识点:Origin由三部分组成:<scheme> "://" <hostname> [ ":" <port> ]
scheme为协议,通常是 HTTP 或 HTTPShostname为主机名,也就是域名或者 IPport为服务器在监听的 TCP 端口号,默认值为 80
参考资料
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
HTTPWhere everything flowsWhere everything flows