-
Notifications
You must be signed in to change notification settings - Fork 755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proxying multiple subdomains #784
Comments
Interested in this as well. |
Hello, does anyone found a solution for handling multiple subdomains ? |
I also need support for this. I've got it proxying a site, injecting my script, and rewriting all links, but going to |
+1 |
Proxying subdomains is possible with http-proxy-middleware. Get the requested domain from let proxy = require('http-proxy-middleware');
bs.init({
middleware: [
function (req, res, next) {
let target = 'http://' + req.headers.host.replace('localhost:3000', 'example.com');
proxy({ target })(req, res, next);
}
]
}); |
It is possible to create several instances of browserSync |
For anyone else who struggled with this, i used @SirAiedail with
|
To further highlight the above: for my project running a local WordPress multisite config via WAMP, I used the following slight modification of the above code by @SirAiedail and it works beautifully- in this case using any sub-domain of middleware: [
function(req, res, next) {
let target = 'http://' + req.headers.host.replace('localhost:3000', 'wp-multisite.local');
proxy({
target,
changeOrigin: true
})(req, res, next);
}
], |
From the above mentioned comments it is clear that by using http-proxy-middleware with browser sync and using the piece of mentioned above will help with subdomain usage but i am basically a tester i am using browser-sync tool to ease my process of Testing i don't have access to Application Source Code in that case then the above mentioned solution would not be feasible solution for me .Please suggest i am struggling to get valid solution |
@sharathp22 You don't need to change your application's code, just the bit that initializes BrowserSync (which is usually part of the development tool chain). |
@SirAiedail Thank you for your reply but i know to create own instance's of Browser sync without any problem it even work's but my problem is we have multiple environment for Testing like Development,Stage and Prod environment for me browser-sync works fine as expected with my Development serve where the applications is deployed on single server and there is no involvement of multiple subdomain where as when we have the application deployed on Staging Server application gets deployed over multiple server and there when the multiple subdomain gets into picture.I hope you understood my scenario. |
@sharathp22 BrowserSync is intended for development workflow only. It should definitely not be used in customer facing deployments (i.e. production). And since "staging" environments are usually intended to replicate the production system, BrowserSync shouldn't be used there either. Additionally, you seem to be using subdomains as a way to address (maybe even load balance) multiple instances of the same application. However, this thread is about handling subdomains (serving entirely different content) within a single instance of an application. That's two very different concepts. |
Hi,
I'm working on a project which uses multiple subdomains for local development.
root domain example: .ecommerce.domain.local
specific site domain: gb.websitename.ecommerce.domain.local
asset domain: css.websitename.ecommerce.domain.local
The subdomains all resolve to the root domain because they point at the same vm ip (via hosts file entries)
I can't get browsersync to load my site on a device using the external url unless that device is a vm running on my machine. If it's my iPhone it fails to load.
Here's my browsersync Gulp settings
I can manage to proxy this setup via proxylocal and proxyreverse. Proxy reverse takes the site domain and uses the --rewrite-domain flag pointing to the root domain.
Any ideas what I can configure to get this working BrowerSync?
The text was updated successfully, but these errors were encountered: