npm - socket.io 设置没有相同站点属性的跨站点 cookie

标签 npm socket.io

我有一个 socket.io 应用程序,最近我收到了这个警告:

A cookie associated with a cross-site resource at URL 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.`



显然,Chrome 将来会更新:
SameSite warning Chrome 77

我已经试过了 this但无济于事:io = io.listen(server, { cookie: false });
我认为 cookie 没有任何作用,那么如何禁用 io 设置呢?

最佳答案

根据 Socket IOs 的 github repo 中报告的问题,该 cookie 不用于任何事情;您可以通过设置 cookie: false 来禁用它在服务器选项中。

但是您错过的是设置 {cookie: false}初始化套接字时的选项,而不是 http.listen .下面提供的解决方案对我有用,它使用 express 作为服务器。

var server = require('http').createServer(express());
var io = require('socket.io')(server, { path:"/some/path", cookie: false });

关于npm - socket.io 设置没有相同站点属性的跨站点 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58557911/

相关文章:

node.js - 在 MongoDB 中存储由 socket.io 创建的套接字

laravel - 我正在使用带有 redis 和 socket.io 的 laravel echo。存在和私有(private) channel 失败

javascript - webpack:找不到模块:错误:无法解析(使用相对路径)

javascript - 错误 : EPERM: operation not permitted, 丑闻

javascript - 使用 github 版本更新 package.json 中的版本

node.js - 单引号在 package.json 中不起作用

angularjs - 节点 amqp + socketio : how to synchronize queue subscribe/unsubscribe?

node.js - 如何创建多个 Nodejs 套接字 io 服务器客户端?

javascript - 诸如socket通信之类的东西需要utf-8编码吗?

node.js - 尝试使用 npm install 时如何解决 NPM "418 I' m a teapot"错误?