SHARE
TWEET

Untitled

a guest Jan 17th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var preAuth = require('http-auth');
  2. var basic = preAuth.basic({
  3.     realm: "Private area",
  4.     file: __dirname + "/htpasswd",
  5.     //Type: "basic"
  6. });
  7.  
  8.  
  9. var server;
  10. var app = express();
  11. app.use(preAuth.connect(basic));
  12.    
  13. app.get('/test', function(req, res) {
  14.     res.send("Hello from express - " + req.user + "!");
  15. });
  16.    
  17. app.use(preAuth.connect(basic));
  18. app.use(express.static(path.join(__dirname, 'public')));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top