Skip to content

Instantly share code, notes, and snippets.

@aprock
Created August 7, 2015 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aprock/e21ed771ff285f5992fc to your computer and use it in GitHub Desktop.
Save aprock/e21ed771ff285f5992fc to your computer and use it in GitHub Desktop.
simple web server that returns www-authenticate
var express = require('express')
var app = express()
app.use(function (req, res, next) {
res.writeHead(401, "Unauthorized",
{ 'Content-Type': 'application/json',
'www-authenticate': 'Basic realm="My Realm"' });
res.end('{"error":[401,"Unauthorized"]}');
console.log('401 refused ' + new Date() + ' (' + (new Date).getTime() + ')');
console.log(req.headers);
next()
})
app.listen(9090);
console.log('Server running at http://127.0.0.1:9090/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment