node.js - Express with Browser-Sync -
i want integrate browsersync express.
i want pull url db , use proxy. setup i've come initializes new browsersync server each request.
is there way accomplish without initializing new browsersync server every time?
or should using approach?
var bs = require("browser-sync"); var express = require("express"); var router = express.router(); var app = express(); router.get("/", function(req, res){ bs.create("bs1").init({ notify: false, open: false, ui: false, port: 10000, proxy: 'http://example.com' }); res.send(); }); app.use(router); app.listen(8080, function(){ console.log('listening on *:8080'); });
so turns out cant done ease.
i ended using express-http-proxy instead , express-vhost subdomains.
app = require('express')(); vhost = require('vhost'); proxy = require('express-http-proxy'); app.use(vhost('sub1.mysite.com', proxy('http://www.example.com'))); app.listen(8080);
hopefully helps 1 day.
Comments
Post a Comment