title: How can I activate CORS in create-react-app?
body: <p>I have created a React App with the create-react-app cli. Now I use an external library do some requests. (I pass the library my backendUrl and it does the request)</p>
  
  <ul>
  <li><code>localhost:3000</code>   My ReactJS App (Webpack)</li>
  <li><code>localhost:8081</code>   My Backend Server</li>
  </ul>
  
  <p>Now this leads to an error, saying the Access-Control-Origin-Header was not sent.</p>
  
  <p>SO I looked into how I can activate this with Webpack. What I have done:</p>
  
  <ol>
  <li><p>Eject Webpack Config to get access to the dev server properties with:</p>
  
  <p><code>npm run eject</code></p></li>
  <li><p>Add following part in the webpack.config.js</p>
  
  <pre><code>devServer: {
  headers: {
    "Access-Control-Allow-Origin": "*",
    "Access-Control-Allow-Headers":
      "Origin, X-Requested-With, Content-Type, Accept"
  }
  </code></pre>
  
  <p>}
  --> Did nothing</p></li>
  </ol>
  
  <p>I then tried to use the proxy mechanism:</p>
  
  <pre><code>"proxy": {
    "/api": {
      "target": "&lt;put ip address&gt;",
      "changeOrigin" : true
    }
  }
  </code></pre>
  
  <p>But since I use an external Library, which doesn't uses fetch and uses the whole URL to make API calls, this also doesn't work, since from my understanding this only proxies requests like <code>fetch("api/items")</code> for example. </p>
  
  <p>I am a bit confused, since I can't find anything online. Maybe I put the things above in the wrong configuration file or line?</p>
  
  <p>There is also a webpackDevServer.config.js but I can't find anything online about it and as soon as I add something to it, it will produce errors.</p>