title: React making axios get, returns error: CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource
body: <p>I am trying to make an axios get request, but i am getting corse policy error. I am kinda new to axios, this is what i tried:</p>
  
  <pre><code>useEffect(() =&gt; {
      let url =
        'http://18.189.49.66:3000/api/calculate/' +
        props.type +
        '/' +
        height +
        '/' +
        width;
  
      var config = {
        headers: { 'Access-Control-Allow-Origin': '*' }
      };
  
      axios.get(url, config).then(_result =&gt; {
        console.log('Duomenys: ' + JSON.stringify(_result));
      });
  
  }, [length, width, height]);
  </code></pre>
  
  <p>In my <code>app.js</code> on node.js express i have these lines:</p>
  
  <pre><code>var cors = require('cors');
  app.use(cors());
  </code></pre>
  
  <p>And here is the error:</p>
  
  <pre class="lang-none prettyprint-override"><code>Access to XMLHttpRequest at 'http://18.189.49.66:3000/api/calculate/LF/80/200'
  from origin 'http://localhost:3000' has been blocked by CORS policy:
  No 'Access-Control-Allow-Origin' header is present on the requested resource.
  
  xhr.js:172 GET http://18.189.49.66:3000/api/calculate/LF/80/200 net::ERR_FAILED dispatchXhrRequest
  @ xhr.js:172 xhrAdapter
  @ xhr.js:11 dispatchRequest
  @ dispatchRequest.js:59 Promise.then (async) request
  @ Axios.js:53 Axios.&lt;computed&gt;
  @ Axios.js:68 wrap
  @ bind.js:9 (anonymous)
  @ Calculator.js:113 commitHookEffectList
  @ react-dom.development.js:22030 commitPassiveHookEffects
  @ react-dom.development.js:22064 callCallback
  @ react-dom.development.js:336 invokeGuardedCallbackDev
  @ react-dom.development.js:385 invokeGuardedCallback 
  @ react-dom.development.js:440 flushPassiveEffectsImpl 
  @ react-dom.development.js:25392 unstable_runWithPriority 
  @ scheduler.development.js:697 runWithPriority$2 
  @ react-dom.development.js:12149 flushPassiveEffects 
  @ react-dom.development.js:25361 flushDiscreteUpdates 
  @ react-dom.development.js:24359 finishEventHandler 
  @ react-dom.development.js:1384 batchedEventUpdates 
  @ react-dom.development.js:1418 dispatchEventForPluginEventSystem 
  @ react-dom.development.js:5894 attemptToDispatchEvent 
  @ react-dom.development.js:6010 dispatchEvent 
  @ react-dom.development.js:5914 ListPicker._handleMouseUp createError.js:16 
  
  Uncaught (in promise) Error: Network Error
      at createError (createError.js:16)
      at XMLHttpRequest.handleError (xhr.js:81)
  </code></pre>
  
  <p>My backend:</p>
  
  <p>...
      var cors = require('cors');
      ...</p>
  
  <pre><code>app.use(cors());
  </code></pre>
  
  <p>...</p>
  
  <p><strong>How should i edit my request?</strong></p>