Created
May 23, 2022 13:52
-
-
Save gayanhewa/89d9edd5faa4bc7402dee6509d822827 to your computer and use it in GitHub Desktop.
Simple basic auth middleware with express-basic-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
const app = require('express')() | |
const basicAuth = require('express-basic-auth') | |
var staticUserAuth = basicAuth({ | |
users: { | |
'Admin': 'secret1234' | |
}, | |
challenge: true, | |
}) | |
app.get('/test', staticUserAuth, (req, res) => { | |
console.log(req); | |
res.send('test'); | |
}); | |
app.listen(3000, function() { | |
console.log("Listening!") | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment