title: How to send preflight request from axios of ReactJS
body: <pre><code>curl -s -v --tlsv1.2 -H &quot;Origin: http://localhost:3000&quot; -F upfile=@_mat/myfile.mp3 -H &quot;Access-Control-Request-Method: POST&quot; -H &quot;Access-Control-Request-Headers: X-Requested-With&quot; -X OPTIONS https://api.aicomposer.net:8008/upload
  </code></pre>
  <p>There is no <code>axios.option</code> thoughm, I made this code.</p>
  <pre><code>  formData.append(
      &quot;upfile&quot;,
      this.state.selectedFile, // _mat/myfile.mp3 is stored from input type=&quot;file&quot; here
      this.state.selectedFile.name // 
    );
  
    const config = {
      headers: {
        &quot;Access-Control-Request-Headers&quot;: &quot;X-Requested-With&quot; ,
        &quot;Access-Control-Request-Method&quot;: &quot;POST&quot;,
        'Origin':&quot;http://localhost:3000&quot;,
      }
    }
    axios.post(`https://api.example.com:8008/upload/`,formData,config).then((res) =&gt;
    {
      console.log(res);
    }).catch(err =&gt;{
        console.log(err);
    });
  </code></pre>
  <p>It shows many errors.....</p>
  <p>Refused to set unsafe header &quot;Access-Control-Request-Headers&quot;
  Refused to set unsafe header &quot;Access-Control-Request-Method&quot;
  Refused to set unsafe header &quot;Origin&quot;</p>
  <p>How can I make the equivalent code to <code>curl</code>??</p>
  <hr />
  <p>THank you for comment.</p>
  <p>I understood axios send preflight request automatically</p>
  <p>However I still not unsure ,how it works.</p>
  <p>For example I attached the header <code>'Content-Type': 'application/json'</code> to GET request.</p>
  <pre><code>  var config = {
      headers: {
        'Content-Type': 'application/json'
      }
    }
    axios.get(`http://api.example.com/upload/`,config).then(res =&gt;{
      console.log(&quot;upload endpoint get OK&quot;);
      console.log(res);
    }).catch(err=&gt;{
      console.log(&quot;upload endpoint get NG&quot;);
      console.log(err);
    });
  </code></pre>
  <p>It doens't show error but,<code>upload</code> connection is called only once in  google developper console.</p>
  <p><a href="https://i.stack.imgur.com/LSKwu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LSKwu.png" alt="enter image description here" /></a></p>