Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp browser-sync proxy

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.

like image 864
user1995781 Avatar asked Jun 08 '26 23:06

user1995781


2 Answers

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

like image 161
Loktar Avatar answered Jun 11 '26 01:06

Loktar


Your json format with options is wrong. Proxy field doesn't have nested properties. Try this one:

browserSync({
        notify: false,
        browser: "chrome",
        proxy: "localhost"
    });
like image 45
niba Avatar answered Jun 11 '26 03:06

niba



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!