Skip to content

Instantly share code, notes, and snippets.

@orbitbot
Created May 8, 2015 11:17
Show Gist options
  • Save orbitbot/3aff20b3ff625f5bffc5 to your computer and use it in GitHub Desktop.
Save orbitbot/3aff20b3ff625f5bffc5 to your computer and use it in GitHub Desktop.
node-proxy-middleware with browser
gulp.task('server', function() {
browserSync({
server: {
baseDir: 'source'
},
logConnections: true,
open: false
});
});
var proxyOptions = require('url').parse('http://localhost:3000');
if (config.proxy) {
winston.warn('config.proxy is set, passing to localhost:3000');
var proxy = require('proxy-middleware');
userLoggedIn = function(req, res, next) {
if (req.isAuthenticated()) {
res.cookie('debug', config['development-mode']);
return proxy(proxyOptions)(req, res, next);
} else {
res.send('<button onclick="location.href=\'/auth'">Login</button>');
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment