3

I'm trying to setup webpack with Hot Module Replacement and reaching it through a reverse proxy in IIS using the Rewrite module

My simple rewrite rule:

<rewrite>
  <rules>
    <clear />
    <rule name="ReverseProxyTEST" stopProcessing="true">
        <match url="^test/(.*)" />
        <action type="Rewrite" url="http://127.0.0.1:8080/{R:1}" logRewrittenUrl="true" />
    </rule>
  </rules>
</rewrite>

i.e. rewriting localhost/test/__webpack_hmr -> localhost:8080/__webpack_hmr

And my webpack config:

var webpack = require('webpack');
var express = require('express');

var config = {
  devtool: 'cheap-module-eval-source-map',
  entry: [
    'webpack-hot-middleware/client?path=http://localhost/test/__webpack_hmr',
    './src/index'
  ],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js',
    publicPath: '/static/'
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
  ...
}

var app = express();
var compiler = webpack(config);

app.use(require('webpack-dev-middleware')(compiler, {
  publicPath: config.output.publicPath
}));

I'm running the webpack server on port 8080 and if I access the site at http://localhost:8080 or manually enter http://localhost:8080/__webpack_hmr in the browser everything works fine.

But if I'm trying to access the site through http://localhost/test or manually enter http://localhost/test/__webpack_hmr in the browser the /test request works as expected but the http://localhost/test/__webpack_hmr request is getting through and remains open but no data is streamed back.

I've verified that the reverse proxy is working. Is there some options in webpack I need to use in order to get this to work?

Cotten
  • 8,787
  • 17
  • 61
  • 98
  • did u find solution for your problem? I have similar problem and I'm stuck at the same point... – PiotrT Jun 25 '18 at 17:42

0 Answers0