简体   繁体   English

Gulpjs从本地网络访问网络服务器

[英]Gulpjs webserver access from local network

I've been using gulpjs task runner for the front-end and I always need to watch how my html files look after them change. 我一直在使用gulpjs任务运行器作为前端,我总是需要观察我的html文件如何看待它们的变化。 So, I've configured the webserver plugin of gulp (live-reload is included), but I want to check my pages from other devices (phones, tablets, eg). 所以,我已经配置了gulp的webserver插件(包括live-reload),但我想从其他设备(手机,平板电脑等)检查我的页面。 My answer is: 我的回答是:

How can I use gulp webserver from other devices of my local network? 如何从本地网络的其他设备使用gulp webserver? Thank you! 谢谢!

gulpjs gulpjs

Unless I'm missing something here, as long as there's not a firewall running on your machine, you should be able to use the local network IP address of your local machine followed by the port number used by the gulp webserver. 除非我在这里遗漏了一些内容,只要您的计算机上没有运行防火墙,您就应该能够使用本地计算机的本地网络IP地址,然后使用gulp webserver使用的端口号。 For example, if your machine IP is 192.168.0.4 and the gulp server is running on port 4000, you should be able to put http://192.168.0.4:4000/ into the browser of another device on your network and access the page. 例如,如果您的机器IP是192.168.0.4并且gulp服务器在端口4000上运行,您应该能够将http://192.168.0.4:4000/放入网络上其他设备的浏览器并访问该页面。

Edit: after looking at the documentation for gulp-webserver, I found this in their FAQ (located on the GitHub readme.md https://github.com/schickling/gulp-webserver ): 编辑:在查看了gulp-webserver的文档之后,我在他们的FAQ(位于GitHub readme.md https://github.com/schickling/gulp-webserver )中找到了这个:

Why can't I reach the server from the network? 为什么我不能从网络到达服务器?

Solution: Set 0.0.0.0 as host option. 解决方案:将0.0.0.0设置为主机选项。

https://github.com/schickling/gulp-webserver https://github.com/schickling/gulp-webserver

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM