跨域饼干在刷新时丢失了

发布于 2025-02-13 12:31:27 字数 279 浏览 4 评论 0原文

我的API(actix-web Rust)托管在render.com和我的前端(VUE 3应用程序)上的vercel.com上。当我登录时,我的API将cookie带有samesite = nonesecure = true和domain render.com。但是,当我刷新或离开页面时,饼干就会丢失。

这是正常的行为吗?如何避免在“重新加载”页面上失去我的跨域cookie?

My API (Actix-web Rust) is hosted on render.com and my frontend (Vue 3 app) on vercel.com. When I log in, my API send a cookie with SameSite=None, Secure=true and domain render.com. But when I refresh or leave the page, the cookie is lost.

Is it a normal behavior? How avoid loosing my cross domain cookie on page reload?

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

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

发布评论

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

评论(1

同展鸳鸯锦 2025-02-20 12:31:28

我认为您需要确保为Cookie设置的域是正确的。

部署在渲染上的网站获取.onrender.com默认情况下的子域(不是.render.com,您可以在需要的情况下添加一个自定义域。请确保您是将cookie域设置为您的后端API域。

I think you need to make sure the domain you set for the cookie is correct.

Sites deployed on Render get an .onrender.com subdomain by default (not .render.com, and you can add a custom domain if you want. Make sure you're setting the cookie domain to your backend API domain.

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