[Node.js] How to set up Basic authentication in Express.js
I’ll introduce how to set up Basic authentication in Express.js.
app.use(express.basicAuth('username', 'password'));
or
app.use(express.basicAuth(function(user, password) {
return user === 'username' && password === 'password';
}));
app.all('/admin/*', express.basicAuth(function(user, password) {
return user === 'username' && password === 'password';
}));
That’s all from the Gemba.