__webpack_hmr goes to the wrong port and fails
<p>I am trying to get hot-reloading to work with my setup. Currently, it works like so --</p>

<p><strong>server.js</strong></p>

<pre><code>// this is the main server, which connects to db, serves react components, etc

const app = express();

app.get('/:params?*', (req, res) =&gt; {
  res.status(200).send(`
    &lt;!doctype html&gt;
    &lt;html&gt;
      &lt;head&gt;
        &lt;meta charset="utf-8"&gt;
      &lt;/head&gt;
      &lt;body&gt;
        hi
        &lt;script src="http://localhost:3000/build/client.js"&gt;&lt;/script&gt;
      &lt;/body&gt;
    &lt;/html&gt;
  `);
});

...
app.listen(5000);
</code></pre>

<p><strong>gulpfile.babel.js</strong></p>

<pre><code>const CLIENT_DEV_CONFIG = {
  entry: [
    CLIENT_ENTRY,
    'webpack-hot-middleware/client',
    'eventsource-polyfill',
  ],
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
  ],
  output: {
    ...CLIENT_OUTPUT,
    publicPath: 'http://localhost:3000/build/',
  },
  module: {
    loaders: [BABEL_LOADER]
  },
}

gulp.task('client-watch', done =&gt; {
  console.log(CLIENT_DEV_CONFIG.output.publicPath);
  const opts = {
    hot: true,
    publicPath: CLIENT_DEV_CONFIG.output.publicPath,
    headers: {'Access-Control-Allow-Origin': '*'},
  };
  const app = new express();
  const compiler = webpack(CLIENT_DEV_CONFIG);
  app.use(webpackDevMiddleware(compiler, opts));
  app.use(webpackHotMiddleWare(compiler));
  app.listen(3000, (err) =&gt; {
    console.log(err || '[webpack-hot-devserver] running on 3000');
    done();
  });
});
</code></pre>

<p>now, </p>

<ul>
<li>If I visit <code>localhost:5000</code>. It works</li>
<li>If I visit <code>localhost:3000/build/client.js</code>, it also works</li>
</ul>

<p>But, if I update something I don't get live updates, I need to refresh... :(</p>

<p>Looking at the network tab, I see a failing request to  <code>http://localhost:5000/__webpack_hmr</code>, and I am thinking this could be the causer.</p>

<p><code>http://localhost:5000/__webpack_hmr</code> should actually be <code>http://localhost:3000/__webpack_hmr</code></p>

<p>However, I am not sure how to correct this</p>