Skip to content

Proxy is extermely slow #161

Description

@grahamb

I am using the proxy option to proxy API requests while using webpack-dev-server. The proxy is extremely slow, to the point where it's useless. I'm trying to test a type-ahead component, and proxying the API request is resulting in 5+ second response times.

webpack-dev-server: 1.8.2
node: 0.12.2

Request through proxy: 5.08 seconds
screen shot 2015-04-23 at 14 55 14

Request direct to API endpoint: 0.03 - 0.06 seconds
screen shot 2015-04-23 at 14 54 58

My webpack.config.js is below:

const webpack = require('webpack');
const path = require('path');
const config = require('config');
const hostname = config.get('dev_server_hostname');
const port = config.get('dev_server_port');

var pragmas = new webpack.DefinePlugin({
  __DEV__: 'true',
  __CANVAS_API_TOKEN__: JSON.stringify(config.get('api_token'))
});

module.exports = {
  devtool: 'eval',

  entry: [
    'webpack-dev-server/client?http://' + hostname + ':' + port,
    'webpack/hot/only-dev-server',
    './src/js/index.js',
  ],

  output: {
    filename: 'canvas_spaces.js',
    path: './dist',
    publicPath: 'http://' + hostname + ':' + port + '/dist/'
  },

  module: {
    loaders: [
      {
        test: /\.js$/,
        loaders: ['react-hot', 'babel-loader'],
        include: path.join(__dirname, 'src')
      },
      {
        test: /\.scss$/,
        loader: "style!css!sass"
      }
    ]
  },

  plugins: [
    pragmas,
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(),
    new webpack.ProvidePlugin({
      'es6-promise': 'es6-promise',
      'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
    })
  ],

  resolve: {
    extensions: ['', '.js', '.jsx'],
    root: __dirname + '/src/js'
  },

  devServer: {
    hot: true,
    host: hostname,
    port: port,
    historyApiFallback: true,
    proxy: {
      '/api/v1/*': config.get('api_proxy'),
      '/font/*': config.get('api_proxy'),
    }
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions