【问题标题】:Can a server check whether a request is coming from an iframe (Node.js)?服务器可以检查请求是否来自 iframe (Node.js)?
【发布时间】:2016-02-15 15:06:50
【问题描述】:
  1. 我希望我的服务器能够检查通过的请求是否来自 iframe

  2. 如果请求来自 iframe,我希望我的服务器能够找到该 iframe 父级的域名

以上是否有可能,如果有,我如何在Node.js/Express.js 服务器中实现这样的检查?

提前感谢您的帮助

【问题讨论】:

  • 这方面有什么更新吗?

标签: node.js iframe server cross-domain


【解决方案1】:

只需在此处查看父母的网址:

request.headers.referer

如果没有 iFrame,它将是未定义的。

【讨论】:

  • Referer 是用户从中导航的 URL。如果页面嵌入在 iframe 中,它可以是父 URL,但也可以是用户访问的最后一个页面。此外,referrerpolicy 可用于阻止将其发送到服务器,因此 absence 的referer 也不一定意味着请求不是来自 iframe
猜你喜欢
  • 1970-01-01
  • 2012-04-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-02-14
  • 1970-01-01
  • 2015-05-27
相关资源
最近更新 更多