I am using two django instances. Both of them are setting the same csrftoken variable, which is causing conflicts. One of the csrftoken cookie is overwritten by other csrftoken cookie. So I am getting CSRF Failed: CSRF token missing or incorrect..

1

There are 1 best solutions below

0
Sairam Gourishetty On

In Django, I renamed one of my csrftoken to be custom-csrftoken using CSRF_COOKIE_NAME. In my front end too, i renamed my csrftoken to be custom-csrftoken.

If the above approach still doesn't work, then it means x-csrftoken header is not being sent in req headers. Try setting CSRF_COOKIE_HTTPONLY = False in django, then X-CSRFToken header will be included in request headers from front end. So There are no more conflicts

This approach resolved my issue.