Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The main assumption is just that you have a single API domain. The fact that the frontend and API may be on different domains doesn't impact this recommendation.

If the API tries to set an HTTPS-only session cookie on api.example.com, the client/browser will simply forward cookie that on every request (including requests made on behalf of a user like a frontend calling fetch()). You can try this yourself, or see it happening in the Github example linked in the post.

If you had backend APIs supported by different domains (api1.example.com and api2.example.com), things do get more troublesome. You could still configure the cookie domain for .example.com, but then you're sending the session cookie along with any request to any example.com subdomain.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: