2 回答

TA贡献1936条经验 获得超7个赞
应用程序将 cookie 路径隐式设置为登录处理程序路径。通过将 cookie 路径显式设置为“/”来修复。
rtCookie := http.Cookie{
Name: "refresh_token",
Path: "/", // <--- add this line
Value: *rt,
Expires: time.Now().Add(time.Nanosecond * time.Duration(sessionLifeNanos)),
}
atCookie := http.Cookie{
Name: "access_token",
Path: "/", // <--- add this line.
Value: *at,
Expires: time.Now().Add(time.Minute * 15),
}

TA贡献1811条经验 获得超6个赞
我不确定,但我认为问题可能是由于 SameSite cookie 政策而出现的。如果您使用现代浏览器版本从在不同端口上运行的前端测试程序,则可能是浏览器不发送 cookie,因为它们没有SameSite 属性。
尝试将您的代码更改为:
rtCookie := http.Cookie{
Name: "refresh_token",
Value: *rt,
SameSite: http.SameSiteNoneMode,
Expires: time.Now().Add(time.Nanosecond * time.Duration(sessionLifeNanos)),
}
- 2 回答
- 0 关注
- 129 浏览
添加回答
举报