Quantcast
Viewing all articles
Browse latest Browse all 26

Answer by Alfred Huang for I am getting an "Invalid Host header" message when connecting to webpack-dev-server remotely

While using the default behavior (no config file) with webpack 5 related to this post: [https://stackoverflow.com/a/65268634/2544762`]

"scripts": {"dev": "webpack serve --mode development --env development --hot --port 3000"    ...    ...},"devDependencies": {    ..."webpack": "^5.10.1","webpack-cli": "^4.2.0"},

With webpack 5 help webpack serve --help:

Usage: webpack serve|server|s [entries...] [options]Run the webpack dev server.Options:  -c, --config <value...>     Provide path to a webpack configuration file e.g.                              ./webpack.config.js.  --config-name <value...>    Name of the configuration to use.  -m, --merge                 Merge two or more configurations using'webpack-merge'.  --env <value...>            Environment passed to the configuration when it                              is a function.  --node-env <value>          Sets process.env.NODE_ENV to the specified value.  --progress [value]          Print compilation progress during build.  -j, --json [value]          Prints result as JSON or store it in a file.  -d, --devtool <value>       Determine source maps to use.  --no-devtool                Do not generate source maps.  --entry <value...>          The entry point(s) of your application e.g.                              ./src/main.js.  --mode <value>              Defines the mode to pass to webpack.  --name <value>              Name of the configuration. Used when loading                              multiple configurations.  -o, --output-path <value>   Output location of the file generated by webpack                              e.g. ./dist/.  --stats [value]             It instructs webpack on how to treat the stats                              e.g. verbose.  --no-stats                  Disable stats output.  -t, --target <value...>     Sets the build target e.g. node.  --no-target                 Negative 'target' option.  --watch-options-stdin       Stop watching when stdin stream has ended.  --no-watch-options-stdin    Do not stop watching when stdin stream has ended.  --bonjour                   Broadcasts the server via ZeroConf networking on                              start  --lazy                      Lazy  --liveReload                Enables/Disables live reloading on changing files  --serveIndex                Enables/Disables serveIndex middleware  --inline                    Inline mode (set to false to disable including                              client scripts like livereload)  --profile                   Print compilation profile data for progress steps  --progress                  Print compilation progress in percentage  --hot-only                  Do not refresh page if HMR fails  --stdin                     close when stdin ends  --open [value]              Open the default browser, or optionally specify a                              browser name  --useLocalIp                Open default browser with local IP  --open-page <value>         Open default browser with the specified page  --client-log-level <value>  Log level in the browser (trace, debug, info,                              warn, error or silent)  --https                     HTTPS  --http2                     HTTP/2, must be used with HTTPS  --key <value>               Path to a SSL key.  --cert <value>              Path to a SSL certificate.  --cacert <value>            Path to a SSL CA certificate.  --pfx <value>               Path to a SSL pfx file.  --pfx-passphrase <value>    Passphrase for pfx file.  --content-base <value>      A directory or URL to serve HTML content from.  --watch-content-base        Enable live-reloading of the content-base.  --history-api-fallback      Fallback to /index.html for Single Page                              Applications.  --compress                  Enable gzip compression  --port <value>              The port  --disable-host-check        Will not check the host  --socket <value>            Socket to listen  --public <value>            The public hostname/ip address of the server  --host <value>              The hostname/ip address the server will bind to  --allowed-hosts <value...>  A list of hosts that are allowed to access the                              dev server, separated by spacesGlobal options:  --color                     Enable colors on console.  --no-color                  Disable colors on console.  -v, --version               Output the version number of 'webpack','webpack-cli' and 'webpack-dev-server' and                              commands.  -h, --help [verbose]        Display help for commands and options.To see list of all supported commands and options run 'webpack --help=verbose'.Webpack documentation: https://webpack.js.org/.CLI documentation: https://webpack.js.org/api/cli/.Made with ♥ by the webpack team.Done in 0.44s.

Solution

So, just add --disable-host-check with the webpack serve command do the trick.


Viewing all articles
Browse latest Browse all 26

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>