I am getting an "Invalid Host header" message when connecting to webpack-dev-server remotely
The problem occurs because webpack-dev-server
2.4.4 adds a host check. You can disable it by adding this to your webpack config:
devServer: {
compress: true,
disableHostCheck: true, // That solved it
}
EDIT: Please note, this fix is insecure.
Please see the following answer for a secure solution: https://stackoverflow.com/a/43621275/5425585
I found out, that I need to set the public
property of devServer, to my request's host value. Being that it will be displayed at that external address.
So I needed this in my webpack.config.js
devServer: {
compress: true,
public: 'store-client-nestroia1.c9users.io' // That solved it
}
Another solution is using it on the CLI:
webpack-dev-server --public $C9_HOSTNAME <-- var for Cloud9 external IP
This is what worked for me:
Add allowedHosts under devServer in your webpack.config.js:
devServer: {
compress: true,
inline: true,
port: '8080',
allowedHosts: [
'.amazonaws.com'
]
},
I did not need to use the --host or --public params.