Created
May 8, 2015 11:17
-
-
Save orbitbot/3aff20b3ff625f5bffc5 to your computer and use it in GitHub Desktop.
node-proxy-middleware with browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task('server', function() { | |
browserSync({ | |
server: { | |
baseDir: 'source' | |
}, | |
logConnections: true, | |
open: false | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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