Skip to content

Instantly share code, notes, and snippets.

@gayanhewa
Created May 23, 2022 13:52
Show Gist options
  • Save gayanhewa/89d9edd5faa4bc7402dee6509d822827 to your computer and use it in GitHub Desktop.
Save gayanhewa/89d9edd5faa4bc7402dee6509d822827 to your computer and use it in GitHub Desktop.
Simple basic auth middleware with express-basic-auth
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