title: Configuring setupProxy.js using http-proxy-middleware
body: <p>I am trying to configure a proxy server ( setupProxy.js ) within a create-react-app using HTTP-proxy-middleware to get access to a weather data API ( api.darksky.net ).</p>
  
  <p>I followed the steps within the React documentation ( <a href="https://facebook.github.io/create-react-app/docs/proxying-api-requests-in-development#configuring-the-proxy-manually" rel="nofollow noreferrer">https://facebook.github.io/create-react-app/docs/proxying-api-requests-in-development#configuring-the-proxy-manually</a> ) but am still having issues with CORS. </p>
  
  <p>I have tried prepending my API URL within my fetch call with '<a href="https://cors-anywhere.herokuapp.com/" rel="nofollow noreferrer">https://cors-anywhere.herokuapp.com/</a>' ( <a href="https://github.com/Rob--W/cors-anywhere/" rel="nofollow noreferrer">https://github.com/Rob--W/cors-anywhere/</a> ) and this is working, but it feels a little corny to me and I'd rather get this working on my own.</p>
  
  <p>Here is the function that is ultimately being called from within componentDidMount: </p>
  
  <pre><code>  fetchWeatherDataAuto = () =&gt; {
      let lat = this.state.locInfo.lat;
      let lon = this.state.locInfo.lon; 
  
      fetch(`https://api.darksky.net/forecast/${apiKey.darkSky_key}/${lat},${lon}`)
        .then(response =&gt; response.json())
        .then(response =&gt; console.log("Weather Response: ", response));
    }
  </code></pre>
  
  <p>Here is the code that is my setupProxy.js file: </p>
  
  <pre><code>const proxy = require('http-proxy-middleware');
  
  module.exports = function(app) {
      app.use(proxy("/forecast", {
            target: "https://api.darksky.net/",
            changeOrigin: true
      }));
  }
  </code></pre>
  
  <p>This error is shown in my console:</p>
  
  <blockquote>
    <p>Cross-Origin Request Blocked: The Same Origin Policy disallows reading >the remote resource at ><a href="https://api.darksky.net/forecast/" rel="nofollow noreferrer">https://api.darksky.net/forecast/</a>{myAPIKey}/9.739>9056,-82.8484079. (Reason: CORS header ‘Access-Control-Allow-Origin’ >missing).</p>
  </blockquote>