I need to send CSRF token when the user sign up with form provided.
However, since the signup/signin will be the first time to interact with django REST API, so I create a dummy GET request when the webpage is loaded to retrieve the CSRF token from django.
The token is retrieved and stored in cookie.
However, I still get Forbidden (CSRF cookie not set.) from django.
This is my axios POST request.
import axios from 'axios'
axios.defaults.xsrfCookieName = 'vcubes'
axios.defaults.xsrfHeaderName = 'X-CSRFToken'
let req = {
    url: 'http://localhost:9000/vcubes/signup/',
    method : 'POST',
    headers: {
        'Content-Type': 'text/plain'
    },
    data: data
}
NOTE:
When I add withCredentials: true into headers in axios POST, the browser send OPTIONS request instead of POST.

 
     
     
    