为什么我的Cookie没有被保存在Safari上,而是被保存在Chrome上?
因此,我正在从事一个项目,前端在Next.js上托管在Vercel上,后端在Heroku上托管的Express.js上。
我正在与Passport JS一起使用明确的课程来存储会话。
在前端,我将Axios用于HTTP调用。会话的饼干被保存在Chrome上,但在Safari上没有保存。我经历了多个Stackoverflow帖子,但没有奏效。野生动物园正在收到标题中的cookie,但没有保存cookie
这里有什么问题?
So I am working on a project, the frontend is on Next.JS hosted on vercel, the backend is on Express.JS hosted on heroku.
I am using express-session along with passport JS to store the sessions.
On the frontend I am using axios for the HTTP calls. The cookie for the session is being saved on Chrome, but on Safari it is not being saved. I have gone through multiple StackOverflow posts but none worked. Safari is receiving the cookie in the header but it is not saving the cookie
Here is my cors configuration on express
What can be the issue here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,事实证明,发生这种情况的原因是因为Safari不允许跨域饼干。因此,解决此问题的唯一真正方法是在同一域的不同子域上托管后端和前端。
Alright, It turns out the reason for this happening is because Safari doesn't allow cross-domain cookies. So, the only true way to resolve this is by hosting the backend and frontend on different subdomains of the same domain.
如果您不能将它们部署在同一域中,则可以在Safari设置(移动和浏览器和浏览器)中关闭
防止跨站点跟踪
,以使其与第三方派对域Cookie一起使用。In cases you can't deploy them within the same domain, you can turn off the
Prevent Cross-Site Tracking
in the Safari settings (both mobile and browser) to make it work with 3rd party domain cookies.