'browsersync doesn't work with XAMPP

I created the project at the address D:\xampp\htdocs\dashboard\optimizedphp (gulpfile.js). What kind of proxy should I use? I tried many, but after changing the php files inside the folder 'app' (D:\xampp\htdocs\dashboard\optimizedphp\app), nothing is restarted. This proxy doesn't work localhost:80/dashboard/optimizedphp/app/

gulp.task('browser-sync', function() {
    browserSync.init({
       proxy: "localhost:80/dashboard/optimizedphp/app/"
});});


Solution 1:[1]

First things, first. What happens when you try to access http://localhost:80/dashboard/optimizedphp/app/ on your browser?

Does it open your app correctly?

If it does, try adding http:// before localhost in your Gulp task, like this:

gulp.task('browser-sync', function() {

   browserSync.init({
      proxy: "http://localhost:80/dashboard/optimizedphp/app/"
   })
;});

Check now, if BrowserSync is correctly pointing to your app.

If it doesn't open your app from http://localhost:80, then there is probably something wrong with your php files or Xampp setup of your project, not BrowserSync.

Solution 2:[2]

I had a bit of trouble with this, but I have it working now, so I thought I might share my config:

browserSync( {
    proxy: "https://localhost/mysite/",
    https: {
        key: "W:/xampp/htdocs/mkcert/localhost/localhost.key",
        cert: "W:/xampp/htdocs/mkcert/localhost/localhost.crt"
    }
});

NB: I am using xampp and it's installed on W:/ drive. I am also using mkcert for SSL.

You can learn more here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bruno Poeta
Solution 2 Mwalek