Skip to content

Upgraded to v2 and proxy now doesn't as expected? #501

@KingScooty

Description

@KingScooty

I'm using an almost identical setup to the one written in the article here => http://ctheu.com/2015/05/14/using-react-hot-loader-with-a-webpack-dev-server-and-a-node-server/

Everything was working great, all my requests were being proxied to my node server.

However, since upgrading to webpack 2.0 and devserver 2.0, the proxying has stopped working. It now just loads the webpack filesystem page, and i can't figure out what's changed to cause it.

Can anyone point me in the right direction? Is there an upgrade guide i'm missing?

// server

  require('babel-register')();
  require('babel-polyfill');
  require('./src/server');

  // we start a webpack-dev-server with our config
  let webpack = require('webpack');
  let WebpackDevServer = require('webpack-dev-server');
  let config = require('./webpack.config');

  const back_server = new WebpackDevServer(webpack(config), {
    hot: true,
    historyApiFallback: true,
    proxy: {
      '*': 'http://localhost:3000'
    }
  });

  back_server.listen(3001, 'localhost', function (err, result) {
    if (err) {
      console.log(err);
    }

    console.log('Listening at localhost:3001');
  });
// webpack.config

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

module.exports = {
  entry: [
    'webpack-dev-server/client?http://127.0.0.1:3001/',
    'webpack/hot/only-dev-server',
    'babel-polyfill',
    './src/client.js'
  ],
  output: {
    path: path.join(__dirname, 'src/dist/'),
    filename: 'bundle.js'
  },
  resolve: {
    modulesDirectories: ['node_modules'],
    extensions: ['', '.js', '.jsx']
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        loaders: ['react-hot', 'babel'] // ,
      }
    ]
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(),
    new webpack.ContextReplacementPlugin(/moment[\\\/]locale$/, /^\.\/(en)$/)
  ],
  devtool: 'inline-source-map'
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions