Cookies Only set in Chrome – not set in Safari, Mobile Chrome, or Mobile Safari

After a battle I’ve figured this out with the help of this post Setting a domain with Express sessions stops cookie from being saved.

The issue comes down to third party cookies.

If you’re sending data from server.herokuapp.com to site.herokuapp.com you’re going to have this issue. The solution is to use the same custom domain for both your frontend and backend Heroku applications.

You should add a custom domain to your frontend and a subdomain to your backend Heroku application. Frontend should look like mywebsite.com and backend should look like server.mywebsite.com.

Within your DNS the subdomain should be server in this example and point to the Heroku DNS target for the backend. The frontend subdomain should be @ or www and point to the Heroku DNS target for the frontend.

Once your applications are being served from the same URL and you have cors set up you will no longer have any third party cookie issues.

You can read more about this here

Leave a Comment