title: Sending x-csrf-token with axios request (Django/Reactjs)
body: <p>I'm trying to send an x-csrf-token with an axios delete request to my django api. Here is the function:</p>
  
  <pre><code>export const deleteTripReport = (tripReport) =&gt; {
    return dispatch =&gt; {
      dispatch(deleteTripReportsPending());
      axios.delete(`http://localhost:8000/api/v1/reports/${tripReport}`)
        .then(response =&gt; {
          dispatch(deleteTripReportsFulfilled());
        })
        .catch(err =&gt; {
          dispatch(deleteTripReportsRejected(err));
        })
    }
  }
  </code></pre>
  
  <p>I've tried adding </p>
  
  <p><code>axios.defaults.xsrfCookieName = 'csrftoken'
  axios.defaults.xsrfHeaderName = 'X-CSRFToken'</code> </p>
  
  <p>below my import. The django server returns 'Forbidden (CSRF Cookie not set'. I've tried adding headers </p>
  
  <pre><code>{headers: {
    'X-Requested-With': 'XMLHttpRequest',
    'X-CSRF-TOKEN': "mkTF7lcI4BVl42lJcFzqNbfeVvoVfLSH7e01kznsEQLYFEoWdchL0tuKZ5HeGnOa",
  }} 
  </code></pre>
  
  <p>with my actual cookie. Then the django server returns OPTIONS instead of DELETE, and the console logs missing 'x-csrf-token'. </p>
  
  <p>I'm running the django server on port 8000 and the react server on 3000 for hot reloads, but I can run build, and both will run on 8000, but currently that is failing as well.</p>