[Vite] Solve the problem of "Network: use --host to expose" reported in the project startup console, and others can also access the project

Problem Description

The project built by Vite displays after running pnpm dev:

problem causes

Because the project is not configured with IP, it can only be started locally, not from IP.

problem solved

Configuring host in vite.config.ts specifies which IP address the server should listen on. If this is set to  0.0.0.0 or  true will listen on all addresses, including LAN and public addresses. If this is the case, as long as the computer and the mobile phone are under the same network, you can also access the mobile project on the mobile phone to see the effect.

all right! In this way, others can also access your project through the network address! 

Guess you like

Origin blog.csdn.net/weixin_42373175/article/details/130241625