title: Set up proxy server for create react app
body: <p>I have started a react application using <a href="https://github.com/facebookincubator/create-react-app" rel="noreferrer">create-react-app</a> and ran the <code>npm run eject</code> script to gain access to all files. I afterwards installed express and created <code>server.js</code> file that sits on same level as <code>package.json</code> file</p>
  
  <p>these are <code>server.js</code> file contents:</p>
  
  <pre><code>const express = require('express');
  const app = express;
  
  app.set('port', 3031);
  
  if(process.env.NODE_ENV === 'production') {
    app.use(express.static('build'));
  }
  
  app.listen(app.get('port'), () =&gt; {
    console.log(`Server started at: http://localhost:${app.get('port')}/`);
  })
  </code></pre>
  
  <p>Nothing crazy here, just setting up for future api proxies where I need to use secrets and as I don't want to expose my api.</p>
  
  <p>after this I added a <code>"proxy": "http://localhost:3001/"</code> to my <code>package.json</code> file. I am now stuck as I need to figure out how to start my server correctly and use this <code>server.js</code> file in development mode and afterwards in production.</p>
  
  <p>Ideally It would also be good if we could use more that one proxy i.e. <code>/api</code> and <code>/api2</code></p>