Last active
August 29, 2015 14:24
-
-
Save mfyz/4d7525297567185d633f to your computer and use it in GitHub Desktop.
express basic http auth
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 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