我的机器上有一个php webserver,它运行在5000端口。
我试图让一个浏览器同步代理与gulp自动刷新它,但它没有返回任何错误无法正常工作。我可以从端口5000访问该页面,因此服务器已启动,我可以访问browserSync UI,因此该过程也是如此。
这是我的一口气
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...
不知道它是否重要,但Web服务器是一个vscode扩展:“PHP Server”。我也已经看到了类似的问题,但没有一个答案有效,我没有安装malwareBytes
在阅读了某些地方(不记得在哪里)localhost
可能导致问题后,我更改了服务器设置以运行127.0.0.1:5000
和browserSync来代理那个并且它工作了