Skip to content

Instantly share code, notes, and snippets.

View xcyxiner's full-sized avatar

xcyxiner xcyxiner

View GitHub Profile
const basicAuthParser = require('basic-auth')
var basicAuth = function (req, res, next) {
const user = basicAuthParser(req)
const validUser = user &&
user.name === process.env.BASIC_AUTH_USER &&
user.pass === process.env.BASIC_AUTH_PASS
if (!validUser) {
res.set('WWW-Authenticate', 'Basic realm=Authorization Required')