简体   繁体   中英

How else do I host my backend free so i could set cookies since heroku can't on *heroku.com domains?

It took me over 24 hours of coding to realize heroku was the problem. ugh! herokuapp.com is included in the Mozilla Foundation's Public Suffix List and because I hosted on the herokuapp.com domain, I also deal with the public suffix issue. How else can I host to avoid this issue? (for free because it's a project I just wanna leave on my portfolio.)

You should be able to set cookies. I can say that because I have done various projects using cookies, hosted on heroku.

Check the following:

  • Cookies work well locally.
  • trust proxy is enabled. Heroku internally routes through multiple proxies, so you require this. Just add app.set('trust proxy', 1); if you're using express.
  • You need to configure cookie options properly while creating them, else you'll run into browser specific issues. Assuming your frontend and backend are hosted on different domains, check if you have sameSite:none and secure:true .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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