UNPKG

http-simple-proxy

Version:

Simple http/https proxy daemon. Proxying based on the excellent node-http-master.

25 lines (23 loc) 637 B
var httpAuth = require('http-auth'); module.exports = function AuthMiddleware() { return { requestHandler: function(req, res, next, auth) { auth(req, res, function(err) { delete req.headers.authorization; next(err); }); }, entryParser: function(authConfig) { if(typeof authConfig === 'object') { authConfig.realm = authConfig.realm || 'Enter password'; } if(typeof authConfig === 'string') { authConfig = { file: authConfig, realm: 'Enter password' } } return httpAuth.connect(httpAuth.basic(authConfig)); } }; };