Skip to content

Instantly share code, notes, and snippets.

@mfyz
Last active August 29, 2015 14:24
Show Gist options
  • Save mfyz/4d7525297567185d633f to your computer and use it in GitHub Desktop.
Save mfyz/4d7525297567185d633f to your computer and use it in GitHub Desktop.
express basic http auth
var express = require('express');
var app = express();
var fs = require('fs');
var auth = express.basicAuth(function(user, pass) {
return user === 'test' && pass === 'pass';
});
app.get('/', auth, function(req, res) {
res.setHeader('Content-Type', 'text/html');
res.send(fs.readFileSync('test.html', 'utf-8'));
});
app.listen();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment