Gulp + BrowserSync 代理未加载

Gulp + BrowserSync proxy not loading

我的机器上有一个 php 网络服务器,它运行在端口 5000 之外。

我正在尝试使用 gulp 获取 browserSync 代理来自动刷新它,但是它无法正常工作且不返回任何错误。我可以通过端口 5000 访问该页面,所以服务器已启动,我可以访问 browserSync UI,因此该进程也已启动。

这是我的 gulp

function watch(){
    browserSync.init(null, {
        proxy: "0.0.0.0:5000",
        port: 5001,
        files: ['*.html', '**/*.css', '**.*.js', '**.*.php']
    });
    gulp.watch("src/**/*.php", reload);
}

这是 运行 的控制台输出:

$ gulp watch
[02:51:57] Using gulpfile gulpfile.js
[02:51:57] Starting 'watch'...
[Browsersync] 1 file changed (index.css)
[Browsersync] 1 file changed (index.js)
[Browsersync] Proxying: http://localhost:5000
[Browsersync] Access URLs:
 --------------------------------------
       Local: http://localhost:5001
    External: http://192.168.128.1:5001
 --------------------------------------
          UI: http://localhost:3001
 UI External: http://localhost:3001
 --------------------------------------
[Browsersync] Watching files...

不知道这是否重要,但网络服务器是 vscode 扩展:"PHP Server"。我也已经看到了类似的问题,但 none 的答案有效,而且我没有安装 malwareBytes

使用 127.0.0.1 而不是本地主机

在某个地方(不记得在哪里)读到 localhost 可能会导致问题后,我将服务器设置更改为 运行 关闭 127.0.0.1:5000 并使用 browserSync 代理它和它工作