This is the 12th day of my participation in the August Text Challenge.More challenges in August
preface
Hello everyone, today we are going to talk about the issues related to accessing vUE local projects through IP addresses under local area networks. In addition, this is a basic class of articles, more suitable for small white reading, because the content of the article comes from my notes when I just entered the line. Ladies and gentlemen, please detour. Thank you
Note in advance: The vUE and vue-CLI versions used in this document are 2.x.
In our development process, the project is run locally, the general address is localhost:8080, so if others want to see the effect, can only see it on our own computer?
No, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no!
1. Set HOST to the specified local IP address
First we need to get the native IP address and then go to build>>webpack.dev.conf.js
Const HOST = process.env.HOST;
Const HOST = ‘192.168.1.139’
(192.168.1.139 is the IP address of the local computer)
2. Change the default startup IP address of the package command
Find: package. Json
“Dev” : “webpack dev – server – the inline – progress – config build/webpack dev. Conf., js”,
Is amended as:
“Dev” : “webpack dev – server – the inline – progress – config build/webpack dev. Conf., js – host 0.0.0.0.” “
Modify localhost
Find the config > > index. Js
Change host: ‘localhost’ to:
Host: ‘0.0.0.0’
4. Close the firewall
I believe that after the above three steps, the basic can access the VUE local project through IP address, if there is no partner, you can check whether the firewall is the ghost. Here we only need to turn off the LAN firewall, network firewall, others can access our project through IP.
I believe that these four steps, in the LAN, you can 100% access their projects through IP!
Of course, now vuE-CLI3 will almost never encounter such problems, we start the project by default will have two access addresses, one of which is the same network through IP address access. Keep a note of this question, though, because it’s a small step on the road to growth.
Afterword.
Hello, I am the South Pole ice cube, a technology and appearance level proportional to the front-end engineer, advocating to solve front-end problems, I hope my blog has helped you.
Pay attention to me and walk together on the front road. Hey ~ 😛