Solve the webpack "Invalid Host header" problem

1. After packaging the project with webpack, you can open it with localhost:8888 and 127.0.0.1:8888 (the port number I set is 8888, you can adjust it yourself);


2. There is a problem with using a domain name



The reason for the problem:

This is because the new version of webpack-dev-server checks the hostname by default for security reasons, if the hostname

Not within the configuration, will break access.

Solution:

You can add the following webpack-dev-server configuration to webpack.base.config.js in the build directory:

devServer:
      disableHostCheck: true,
    },

The domain name is used again to access successfully:


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324823401&siteId=291194637