我有一个 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 withSameSite=None
andSecure
.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/