Skip to content

Instantly share code, notes, and snippets.

@modeswitch
Created June 19, 2017 20:50
Show Gist options
  • Save modeswitch/d8fb5483f7015ee8de88afc268218fc6 to your computer and use it in GitHub Desktop.
Save modeswitch/d8fb5483f7015ee8de88afc268218fc6 to your computer and use it in GitHub Desktop.
basic auth
const express = require("express");
let app = express();
let basicAuth = require("express-basic-auth");
app.use(basicAuth({
users: {
"brainsights": "donthackus",
},
challenge: true,
unauthorizedResponse: (req) => {
return req.auth ?
(`Credentials ${req.auth.user}:${req.auth.password} rejected`) :
`No credentials provided`;
},
}));
app.listen(process.env["PORT"] || 8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment