简体   繁体   English

Cookie 未在 Live 网站上保存

[英]Cookies not getting Saved on Live website

I hosted my client side on Netlify and backend on Heroku.我在 Netlify 上托管我的客户端,在 Heroku 上托管后端。 Everything is working fine locally, but as soon as I deployed the changes live it stopped working.一切都在本地运行良好,但是一旦我实时部署了更改,它就停止了工作。

  1. Locally in my client side, I have added proxy in package.json like "proxy": "localhost:5000" (Server was running on 5000 port locally) and it is working and I am able to store cookies in Chrome.在我的客户端本地,我在package.json中添加了代理,例如"proxy": "localhost:5000" (服务器在本地的 5000 端口上运行)并且它正在工作,我可以在 Chrome 中存储 cookie。

  2. After deploying to Netlify, I just removed the proxy, the user is getting saved successfully in MongoDB which is live but cookies are not getting saved.部署到 Netlify 后,我刚刚删除了代理,用户在 MongoDB 中成功保存,但 cookie 没有保存。

I am not sure what I'm doing wrong, since everything is working in local.我不确定我做错了什么,因为一切都在本地工作。

You do need a custom domain set for your app.您确实需要为您的应用设置自定义域。

herokuapp.com is included in the Mozilla Foundation's Public Suffix List. herokuapp.com包含在 Mozilla 基金会的公共后缀列表中。 This means that in browsers that support the functionality (eg. Firefox, Chrome, Opera), applications in the herokuapp.com domain are prevented from setting cookies for *.herokuapp.com .这意味着在支持该功能的浏览器(例如 Firefox、Chrome、Opera)中,禁止 herokuapp.com 域中的应用程序为*.herokuapp.com设置 cookie。

As perhttps://devcenter.heroku.com/articles/cookies-and-herokuapp-com根据https://devcenter.heroku.com/articles/cookies-and-herokuapp-com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM