同事开发前端项目,通过webpack-dev-server起的服务,本地localhost:300正常访问,而同一个局域网内其他同事无法通过她机器ip访问。
解决方法:
(If you're on a Mac and network like mine.)
Run webpack-dev-server with --host
0.0.0.0 — this lets the server listen for requests from the network, not just localhost.
Find your computer's address on the network. In terminal, type ifconfig and
look for the en1section
or the one with something like inet
192.168.1.111
In your mobile device on the same network, visit http://192.168.1.111:8080 and
enjoy hot reloading dev bliss.
参考:https://stackoverflow.com/questions/35412137/how-to-get-access-to-webpack-dev-server-from-devices-in-local-network
https://github.com/webpack/webpack-dev-server/issues/147
本文介绍了解决前端项目中Webpack-dev-server仅限本地访问的问题。通过设置--host 0.0.0.0使服务器接受来自局域网的请求,并提供如何查找本机IP地址的方法,最终实现跨设备访问。
2660

被折叠的 条评论
为什么被折叠?



