Skip to content

Instantly share code, notes, and snippets.


Luis Lopez Cardona luis815

View GitHub Profile
flesch / basic-auth.js
Last active Apr 9, 2021
HTTP Basic Authentication with Express, without express.basicAuth.
View basic-auth.js
var express = require("express");
var app = express();
app.get("/restricted", function(req, res, next){
// Grab the "Authorization" header.
var auth = req.get("authorization");
// On the first request, the "Authorization" header won't exist, so we'll set a Response
// header that prompts the browser to ask for a username and password.