The webpack project from vue-cli can be accessed with localhost, but it cannot be accessed by switching to ip

https://www.cnblogs.com/wangyanhua95/p/7954019.html

I am using a project from vux (mobile terminal, based on vue), because it is a mobile terminal, it needs to be tested on the mobile phone, and I found that it is very good to use localhost:8081/ to access, but I can't access it when I change to ip, at the beginning of the period I thought it was because of the proxy, so I turned off the proxy on the computer. It still doesn't work, then change to 127.0.0.1 to access, and find that it can be accessed, and 0.0.0.0 can also be used, but ip can't. Then all kinds of google, Baidu. Other people's methods---I have tried a lot, and found that it doesn't work (a little doubt about life, whether it is my computer's problem), but the result is here, ip is not accessible! ! ! !

In line with a programmer's instinct - do not solve this bug, never give up the spirit. I started looking at my build file, the config file. Finally found the root ---- in the config in the index.js in the module.exports under the dev under the host:'localhost' changed to host:'0.0.0.0', you can access it! ! ! Then happily start coding! ! ! ! ! !

Guess you like

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