I am facing a big problem with my sessions in a Django project.
The back-end is hosted at .my-domain.org
and the front-end consumes the REST API of the back-end at .front-end.com
. In the future, other front-ends on completely different domains might appear.
How do I deal with such a situation when I use the session framework provided by Django? It seems like SESSION_COOKIE_DOMAIN
only allows session cookies to be set on one subdomain. The result is that if I want to be able to login at .my-domain.org
(i.e., SESSION_COOKIE_DOMAIN = None
) then I am not able to receive the session cookie back from .front-end.com
when it calls API endpoints. On the other hand, setting SESSION_COOKIE_DOMAIN
to .front-end.com
would prevent me to connect to the site admin. The situation is also impacted by SESSION_COOKIE_PATH
of course...
Any help is more than welcome. I am quite sure I'm not the first one who needs a REST API with session authentication to be accessible from external domains.