title: Ajax With ReactJS to NodeJS
body: <p>I'm using webpack-dev-server while developing in ReactJS.<br>
  I also want to add a backend which will be written in NodeJS.<br>
  When I run the webpack-dev-server it binds to port 8080.<br>
  When I run node, it can't bind to the same port.<br>
  Therefore, I'm unable to perform $.ajax requests due to the SOP.<br>
  How do I get over this issue?</p>
  
  <p>NodeJS:</p>
  
  <pre><code>const express = require('express');
  
  const app = express();
  
  app.get('/messages', function(req, res){
    res.send('hello world!');
  });
  
  let server = app.listen(8081, function() {
    const host = server.address().address;
    const port = server.address().port;
  
    console.log('Listening at http://%s:%s', host, port);
  });
  </code></pre>
  
  <p>React/JS/Ajax:</p>
  
  <pre><code>$.getJSON('/messages', function(data) {
    this.setState({
      messages: data
    });
  }.bind(this));
  </code></pre>
  
  <p>And I'm running <code>webpack-dev-server</code> without any parameters.</p>