Invalid Host header


#1

My server.js file is following, when click the preview, I got the error message: Invalid Host header

var webpack = require("webpack");
var WebpackDevServer = require("webpack-dev-server");
var config = require("./webpack.config.js");
config.entry.app.unshift("webpack-dev-server/client?http://localhost:3000/");
var compiler = webpack(config);
var server = new WebpackDevServer(compiler);
server.listen(3000, "localhost");

#2

It’d be helpful if you can provide the project name so I can take a proper look, but I’m assuming it’s not liking the localhost - try 0.0.0.0.


#3

Hi @Gareth, thank you. Here is my project: https://glitch.com/edit/#!/test-glitch

I also tried the 0.0.0.0, the result is the same.


#4

I fixed the issue by modify the following line:

var server = new WebpackDevServer(compiler, {
  disableHostCheck: true
});

#5

hah, yes - I was just looking at https://github.com/webpack/webpack-dev-server/issues/882 and it mentions that or specifically using 2.4.2, which worked too.


#6

Yes, my solution is also come from there.