更新于 

Vite

Vite配置

Network: use --host to expose

问题描述

npm run dev之后,不能通过IP + 端口的方式访问到服务页面。
控制台有提示信息:

Network: use --host to expose

解决方法

参考csdn博主“勇敢的阿呆”博客

vite.config.js 中加入 server 配置:

1
2
3
4
5
6
...
server:{
port:xxxx, // 端口号
host:true
}
...