Acquiring CSRF token from Django when index.html is served by nginix Acquiring CSRF token from Django when index.html is served by nginix nginx nginx

Acquiring CSRF token from Django when index.html is served by nginix


CSRF token is always updated with each page load. It has to be served by django since django is the application that provides and validates it. Place the index.html file in your django templates folder, serve it with your index view, translate CSRF token to javascript code and use it in your ReactJS code

index.html

...<body><script>     var csrftoken = '{{ csrf_token }}';</script>...</body>...