当用户使用 Safari/iOS 时无法在 res 处发送 cookie

问题描述 投票:0回答:1

使用 Node.js 和 Express.js 构建 Web 服务器 我在回复中附加了 cookie

res.cookie('token', token, {
    httpOnly: true,
    expires: new Date(Date.now() + sixMonths),
    secure: true,
    sameSite: 'none',
    signed: true,
  });

当用户使用 chrome 或 mozilla 时,一切都按预期工作,但在 safari 上,由于无法处理交叉 cookie,出现身份验证错误,有什么解决方案吗?

解决express cookie问题

node.js express cookies safari
1个回答
0
投票

当前您正在设置

sameSite: 'none'
,因此您告诉会话您将使用跨域。要实现此功能,请添加值
sameSite: true

© www.soinside.com 2019 - 2024. All rights reserved.