使用 XAMPP 和 Laravel 时 iframe 拒绝连接

iframe refused to connect while using XAMPP and Laravel

我正在开发一个 Laravel 应用程序并添加了一个 iframe,如下所示:

iframe 没有连接,只是说 www.google.com 拒绝连接。我做了一些研究,这似乎与正在设置的 X-Frame-Options 有关。在 Chrome 浏览器开发人员工具中,我看到以下错误消息:

https://www.google.com/ was set without the SameSite attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with SameSite=None and Secure. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032 处的跨站点资源关联的 cookie。

我猜这是一个需要在 Apache 中的 XAMPP 服务器级别更改的设置,但我不知道在哪里。有什么想法吗?

如果您在本地主机上进行测试并且您无法控制响应 headers,您可以使用 chrome 标志禁用它。

打开这个 URL :

chrome://flags/#same-site-by-default-cookies

并禁用SameSite by default cookies

SameSite 阻止浏览器随 cross-site 请求一起发送 cookie。

如果您不想禁用 SameSite by default cookies 您可以在发回响应之前添加响应 header 以解决此问题:

return response($content)
              ->header("Set-Cookie", "HttpOnly;Secure;SameSite=Strict");