title: Cross-Origin Resource sharing error: Header Disallowed by preflight response
body: <p>i am learning how to use react as a front end and django as a backend. i am getting these cors issue everytime im hitting post method to django server. It is a very application. Sending a value from react to django server and printing it. In Django server terminal it shows  &quot;OPTIONS /sample HTTP/1.1&quot; 200 0
  and in react it is showing cors error. i added all the different kinds but the problem still exists
  <code>enter code here</code></p>
  <pre><code>React Component Code
  import axios from 'axios'
  import React, { Component } from 'react'
  import App from '../App';
  axios.defaults.xsrfHeaderName = &quot;X-CSRFTOKEN&quot;;
  axios.defaults.xsrfCookieName = &quot;XCSRF-TOKEN&quot;;
  
  class addProduct extends Component {
   constructor(props) {
      super(props)
      this.state  = {
          testId : '12324',
        }
  
      this.ButtonClicked = this.ButtonClicked.bind(this)
  }
  ButtonClicked =(e) =&gt; {
    e.preventDefault()
    console.log(this.state)
    axios({
          method: 'post',
          url: 'http://127.0.0.1:8000/sample',
          data: this.state.testId,
          crossDomain: true,
          mode : 'CORS',
          headers: {
              &quot;Access-Control-Allow-Origin&quot;: &quot;*&quot;,
              &quot;Access-Control-Allow-Methods&quot;: &quot;GET,HEAD,OPTIONS,POST,PUT&quot;,
              &quot;Access-Control-Allow-Headers&quot;: &quot;Origin, Content-Type&quot;,
              &quot;Access-Control-Max-Age&quot; : &quot;200&quot;
            }
          
      })
      .then(Response =&gt; console.log(Response.data))
    }
  
     render() {
      
      return (
          &lt;div className = &quot;addProduct&quot;&gt;
  
              &lt;button  type = &quot;submit&quot; onClick = {this.ButtonClicked} &gt;Start&lt;/button&gt;
                     
          &lt;/div&gt;
        )
      }
     }
  
   export default addProduct 
  
  
  
     Django Code:
     from django.shortcuts import render
     from django.http import HttpResponse
     # Create your views here.
    def showsample(request):
       username = request.POST.get('testId')
  
       print(&quot;the value is &quot; ,username)
  
       return HttpResponse(&quot;hello world&quot;)
  </code></pre>
  <p>In the browser Network options it shows :</p>
  <p>Requested url: <a href="http://127.0.0.1:8000/sample" rel="nofollow noreferrer">http://127.0.0.1:8000/sample</a>
  Referrer Policy: strict-origin-when-cross-origin</p>
  <p>Request Headers:
  with a warning symbol : Provisional headers are shown</p>
  <p>Accept: application/json, text/plain, <em>/</em></p>
  <p>Access-Control-Allow-Headers: Origin, Content-Type</p>
  <p>Access-Control-Allow-Origin: *</p>
  <p>Content-Type: application/x-www-form-urlencoded</p>
  <p>Referer: http://localhost:4200/
  sec-ch-ua: &quot; Not A;Brand&quot;;v=&quot;99&quot;, &quot;Chromium&quot;;v=&quot;90&quot;, &quot;Google Chrome&quot;;v=&quot;90&quot;
  sec-ch-ua-mobile: ?0
  User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36</p>
  <p>When  double click on the &quot;sample&quot; which is highlighted in red color.</p>
  <p>Then the post request is passing and I can see the output on the Django terminal and HTTP Response of helloworld</p>