title: How to use the CORS npm module
body: <p>I have set up a very basic example to get the cors module working so that I can make an axios call from a react front end to an express js server.</p>
  
  <p>React front end</p>
  
  <pre><code>import React from 'react';
  import Axios from 'axios'
  import './App.css';
  import 'bootstrap/dist/css/bootstrap.css';
  
  function App() {
  
    const callTest = () =&gt;{
      console.log("test called")
      Axios.get('http://localhost/5000/testCall')
      .then((res) =&gt; {
        console.log(res.data)
      })
    }
  
    return (
      &lt;div className="App"&gt;
        &lt;div class="row"&gt;
          &lt;div class="col-12"&gt;
            &lt;p&gt;Welcome to the CORS test&lt;/p&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="row"&gt;
          &lt;div class="col-12"&gt;
            &lt;button onClick={() =&gt; callTest()}&gt;Click to run test function&lt;/button&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    );
  }
  
  export default App;
  
  </code></pre>
  
  <p>Express node server</p>
  
  <pre><code>const express = require('express')
  const bodyParser = require('body-parser')
  const cors = require('cors')
  
  var app = express()
  app.use(cors())
  
  const port = 5000
  
  app.get('/testCall', (req,res) =&gt;{
      console.log("test call function has been called!!")
      res.send("Hello from the node server")
  })
  
  app.get('/', (req,res) =&gt;{
      console.log("this was called")
  })
  
  app.listen(port, (req,res) =&gt;{
      console.log("app is running on port " + port)
  })
  
  </code></pre>
  
  <p>However I am getting the following error in my browser.</p>
  
  <p>Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at <a href="http://localhost/5000/testCall" rel="nofollow noreferrer">http://localhost/5000/testCall</a>. (Reason: CORS request did not succeed).</p>
  
  <p>Anybody got any ideas as to what i'm missing?</p>