kculmback's avatar

Browsersync not proxying Homestead or Valet url

I'm attempting to get mix to proxy my app url with either Homestead or Valet. However, browsersync will not load or auto-refresh with that url (such as 'example.test'). It will work with the default localhost:3000 URL.

So, for example, when I go to localhost:3000, I get the message 'browsersync connected' and the auto-refresh will happen when files are saved. But when I go to 'test.com', there is no browsersync message and no auto-refresh.

I just started this project so everything is completely up to date. Here's my mix settings:

mix.js('resources/assets/js/app.js', 'public/js')
  .sass('resources/assets/sass/app.scss', 'public/css')
  .browserSync({
    proxy: 'example.test',
    open: false,
});

I've attempted playing with the port option as well without any luck. I've also done this from both inside the VM (for Homestead) and in the project folder on my computer. I've also experienced this on two different computers.

Apologies if I am missing something painfully obvious, but I have been trying to figure this out for a while now and cannot get it to work, unfortunately. Any help would be greatly appreciated.

0 likes
7 replies
LaravelFreelancerNL's avatar

Does your test domain work without browsersync?

Also which virtualisation software are you using (Virtualbox, Hyper-V)?

kculmback's avatar

Yes, I can go to 'example.test' without browsersync.

Homestead is set up to us Virtualbox and Valet I don't believe uses any of those programs. Here is the Homestead.yaml file if it's of any help:

ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/www/example
      to: /home/vagrant/code/example
      type: "nfs"

sites:
    - map: example.test
      to: /home/vagrant/code/example/public

databases:
    - example
LaravelFreelancerNL's avatar
Level 10

Just to be sure, are you trying example.test or example.test:3000? The latter you will need for BrowserSync, the first is just the regular serving by Homestead.

Another thing you can check is to see if you can reach the BrowserSync UI at localhost:3001 & example.test:3001

1 like
rin4ik's avatar

@kculmback this should work

.browserSync({
        open: 'external',
        host: 'example.test',
        proxy: 'example.test',
    });
1 like
kculmback's avatar

@LaravelFreelancerNL I was opening example.test, not example.test:3000. example.test:3000 worked! I figured it was something quite simple that I was missing ? Thank you for your help!

@rin4ik thank you for your help as well!

1 like
rin4ik's avatar

@kculmback does it work with this ?

  .browserSync({
    proxy: 'example.test',
    open: false,
});
LaravelFreelancerNL's avatar

Yep, it's easy to miss. Been there, done that, got the T-shirt.

I'm glad you got it working!

Please or to participate in this conversation.