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

Request direct to API endpoint: 0.03 - 0.06 seconds

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'),
}
}
}
Never mind, this looks like it's a DNS-related problem. I'm proxying to a vagrant box; when I change to using its IP address everything is snappy.
I have the same issue, thanks for your finding, it helped me too.
Same issue experienced using recommend instructions with create-react-app. Thanks for sharing solution :)
Never mind, this looks like it's a DNS-related problem. I'm proxying to a vagrant box; when I change to using its IP address everything is snappy.
Thanks for sharing solution. It works
Most helpful comment
Never mind, this looks like it's a DNS-related problem. I'm proxying to a vagrant box; when I change to using its IP address everything is snappy.