Cause Analysis of vue-cli failure to access the local service LAN

Source: Internet
Author: User

Cause Analysis of vue-cli failure to access the local service LAN

1. Problem description:

The local vue-cli starts a project and can only be accessed through localhost: 8080. Other mobile phones and computers in the same LAN cannot access and debug through IP addresses,

2. cause: the vue-cli project is generated with one click through the command line. The local debugging mode is generated by default in the configuration file, and the default access address is localhost: port number.

3. method of correction

Find the index. js file in the config folder and Modify host: "localhost" TO host: "0.0.0.0". At this time, the mobile phone and other computers in the same LAN can view the page through ip address.

PS: The following figure shows that the webpack project started with vue-cli can be accessed using localhost, but cannot be accessed by switching to an ip address.

I am using a vux Project (Mobile End, based on vue). Because it is a mobile end, I need to test it on the mobile phone and find that http: // localhost: 8081/the access is quite good, but it cannot be accessed by switching to an ip address. At the beginning of this period, I thought it was the reason for proxy. I turned off the computer proxy. Still not good, and then changed to 127.0.0.1 access, found that can access, with 0.0.0.0 access can also be, that is, the ip is not good. Then there will be a variety of google and Baidu. Other people's methods-They tried a lot and found that they were ineffective (a little skeptical about life, maybe my computer problems), but the result is here, ip is not accessible !!!!

In the spirit of a programmer's instinct-Never give up without solving this bug. I started to view my build file and config file. Finally, the root cause is found-the index in config. module in js. change 'localhost' under dev under exports to host: '0. 0.0.0 ', you can access it !!! Then start code happily!

Summary

The above is an analysis of the reason why vue-cli cannot be accessed when the local service LAN is started. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.