I am trying to setup browser-sync to work via proxy:
gulp.task('browser-sync', function() {
browserSync({
notify: false,
browser: "chrome",
proxy:{
host:"localhost"
}
});
});
The problem is it seems cannot work with proxy directly, instead request for manually putting in snippet into website.
However, if I try with global browser-sync browser-sync start --proxy "localhost", it works.
How can I get the gulp browser-sync's proxy works? Or, how can I have the global browser-sync to work with gulp? It is important, so that browser-sync can work with my gulp logic and reload browser when needed.
According to the docs you should be using target rather than host.
proxy: {
target: "http://yourlocal.dev"
}
Or simply
proxy: "local.dev"
like @niba has in his answer
Your json format with options is wrong. Proxy field doesn't have nested properties. Try this one:
browserSync({
notify: false,
browser: "chrome",
proxy: "localhost"
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With