Answer the question
In order to leave comments, you need to log in
How to send post requests to a subdomain?
There is a project with two subdomains: forum.site.com and games.site.com, when sending an ajax post request from one subdomain to another server, it is rejected, since csrf and sessionid tokens are not sent from cookies. Inside one domain, the code works properly.
Subdomains have utilities that are useful to me, I would like to use them without duplicating urls, if this is not possible, then tell me the correct
settings.py architecture
SESSION_COOKIE_DOMAIN = 'site.com'
CSRF_COOKIE_DOMAIN = 'site.com'
CSRF_COOKIE_NAME = 'csrftoken'
CSRF_TRUSTED_ORIGINS = ['games.site.com', 'forum.site.com']
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'corsheaders.middleware.CorsPostCsrfMiddleware',
...,
...,
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question