title: Axios, POST request to Flask
body: <p>I try to make a POST to a flask server using axios:</p>
  
  <pre><code>var config = { headers: {  
                        'Content-Type': 'application/json',
                        'Access-Control-Allow-Origin': '*'}
               }
   axios.post("http://127.0.0.1:5000/test", 
               { label : "Test" , text : "Test"}  , config
            )
            .then(function (response) {
              console.log(response);
            })
            .catch(function (error) {
              console.log(error);
            });
  </code></pre>
  
  <p>Now the part of Flask</p>
  
  <pre><code>...
  data = request.get_json(silent=True)
  item = {'label': data.get('label'), 'text': data.get('text')}
  print item
  ...
  </code></pre>
  
  <p>However, I ll end up with the following error:</p>
  
  <p>XMLHttpRequest cannot load <a href="http://127.0.0.1:5000/test" rel="nofollow noreferrer">http://127.0.0.1:5000/test</a>. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://localhost:3000" rel="nofollow noreferrer">http://localhost:3000</a>' is therefore not allowed access.</p>
  
  <p>Why? I LL set the header as suggested.</p>
  
  <p>Here the solution</p>
  
  <pre><code>from flask_cors import CORS, cross_origin
  app = Flask(__name__)
  cors = CORS(app, resources={r"/YOURAPP/*": {"origins": "*"}})
  </code></pre>