I'm trying to setup a simple auth using http-auth module.
I've created this setup but it's not working properly. The dialog prompting the user/pass show up but if I close the dialog the app continues to work, that is, the auth don't seem to be working.
Seem that's not working because I've tried to setup this http-auth
to work in my static folder www
.
My app.js
is based on this one.
Here is my setup:
'use strict';
var express = require('express');
var app = express();
var auth = require('http-auth');
app.use(express.static('www'));
var basic = auth.basic({
realm: 'SUPER SECRET STUFF'
}, function(username, password, callback) {
callback(username == 'username' && password == 'password');
});
app.use("/", auth.connect(basic));
app.set('port', (process.env.PORT || 4000));
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});