跨域饼干在刷新时丢失了
我的API(actix-web Rust)托管在render.com
和我的前端(VUE 3应用程序)上的vercel.com
上。当我登录时,我的API将cookie带有samesite = none
,secure = 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要确保为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.