为什么我的Cookie没有被保存在Safari上,而是被保存在Chrome上?

发布于 2025-01-28 09:56:06 字数 590 浏览 3 评论 0原文

因此,我正在从事一个项目,前端在Next.js上托管在Vercel上,后端在Heroku上托管的Express.js上。

我正在与Passport JS一起使用明确的课程来存储会话。

在前端,我将Axios用于HTTP调用。会话的饼干被保存在Chrome上,但在Safari上没有保存。我经历了多个Stackoverflow帖子,但没有奏效。野生动物园正在收到标题中的cookie,但没有保存cookie

这是我在Express上的CORS配置

这里有什么问题?

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
Cookie being received on Safari

Here is my cors configuration on express
cors configuration

What can be the issue here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

仙气飘飘 2025-02-04 09:56:06

好吧,事实证明,发生这种情况的原因是因为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.

冬天旳寂寞 2025-02-04 09:56:06

如果您不能将它们部署在同一域中,则可以在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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文