Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

浏览器的 Referrer-Policy #98

Closed
Dream4ever opened this issue Oct 13, 2020 · 0 comments
Closed

浏览器的 Referrer-Policy #98

Dream4ever opened this issue Oct 13, 2020 · 0 comments
Labels
HTTP Where everything flows

Comments

@Dream4ever
Copy link
Owner

Dream4ever commented Oct 13, 2020

问题起因

最近在测试后端 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 或 HTTPS
  • hostname 为主机名,也就是域名或者 IP
  • port 为服务器在监听的 TCP 端口号,默认值为 80

参考资料

@Dream4ever Dream4ever added Front-end Everything you see and experience Back-end Where data really come and go labels Oct 13, 2020
@Dream4ever Dream4ever changed the title 各浏览器的 Referrer-Policy 设置 浏览器的 Referrer-Policy 设置 Oct 13, 2020
@Dream4ever Dream4ever added Browser All about browsers HTTP Where everything flows and removed Back-end Where data really come and go Front-end Everything you see and experience Browser All about browsers labels Oct 13, 2020
@Dream4ever Dream4ever changed the title 浏览器的 Referrer-Policy 设置 浏览器的 Referrer-Policy Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HTTP Where everything flows
Projects
None yet
Development

No branches or pull requests

1 participant