Support multi-domain setups and create a proxy middleware for each domain
@mmunz Thanks for PR.
Could you some steps here I can follow so I can test it?
@tyler36 i created a ddev test setup here: https://github.com/mmunz/browsersynctest/tree/multiple-domain-support
It is a ddev setup with an additional hostname and two docroots.
To test it do:
- checkout the test project (multiple-domain-support)
- ddev get ddev/browsersync to get the original version
- ddev start
- ddev browsersync
- open https://browsersynctest.ddev.site:3000 and https://browsersynctest2.ddev.site:3000/ - they both show the same text because the proxy uses the first hostname (browsersynctest.ddev.site)
- ddev stop
- ddev get https://github.com/mmunz/ddev-browsersync/tarball/support-multidomain-setups
- ddev start
- ddev browsersync
- https://browsersynctest2.ddev.site:3000/ should now show different text and test in red. (If text is not red: this is probably the browser cache)
@mmunz
I had a look at the PR today.
Using this ddev get https://github.com/mmunz/ddev-browsersync/tarball/support-multidomain-setups
After running it, I opened https://browsersynctest.ddev.site:3000/ & https://browsersynctest2.ddev.site:3000/;
Changes made to browsersynctest1/index.html reload both pages.
Changes made to browsersynctest2/index.html triggers nothing.
Is that the expected behavior?
@mandrasch would this have helper for your use case (#27) ?
@tyler36 i have to look deeper into this, but i suspect this is same strange caching issue (browser cache or even the http-proxy-middleware).
@mandrasch would this have helper for your use case (#27) ?
Can't really say. While reading through the steps provided by @mmunz I just noticed that I never used the ddev browsersync command...
I just installed ddev-browsersync to open up the port via the docker-compose file...In LaravelMix browsersync was controlled by the package itself (https://laravel-mix.com/docs/6.0/browsersync), see also my answer https://github.com/ddev/ddev-browsersync/issues/27#issuecomment-1322656310. Guess my issue was more a docs-related one to LaravelMix integration.
Much success solving this!
@tyler36 The problem was, that in the demo project the public folder was not properly watched. I've updated https://github.com/mmunz/browsersynctest/tree/multiple-domain-support to watch for files in public in browser-sync.js now.
Sorry for the delayed response. Is this still valid and a "good" approach?
@tyler36 well, it's the best solution for the problem i came up with. I'm also using it in my own multidomain projects. The downside is that it adds a bit of complexity.
But i'd love to hear from others, if they use this approach and if it works, or if there exist better solutions.
Thank you for your work on this.
Due to lack of demand from the community, I'm going to close this for now.
I'm happy to re-open if there's a push in demand or if you feel strongly.