Proxy URL not working with BrowserSync Gulp task

Cofey picture Cofey · Feb 17, 2015 · Viewed 16.2k times · Source

Can someone tell me why my proxy URL isn't working with BrowserSync and Gulp? Instead, it just keeps using http://localhost:3000 as the dev URL.

gulp.task('watch', ['bs'], function() {
  gulp.watch('scss/*.scss', ['scss', browserSync.reload]);
});

gulp.task('bs', function() {
    browserSync.init(['css/style1.css', 'css/style2.css'], {
      proxy: 'dev.site.com'
    });
});

gulp.task('default', ['scss', 'watch']);

Answer

Maximilian Lindsey picture Maximilian Lindsey · Nov 5, 2015

I had the same problem and did the following to stop browser-sync from using the default adress/port:

gulp.task('bs', function () {
    browserSync.init(null, {
        proxy: 'localhost:8080', // 'dev.site.com' in your example
        port: 5000
    });
});

This worked for me and change the browser-scyn adress to localhost:5000