Here's a quick server I whipped up as a proof-of-concept:
var express = require('express');
var app = express();
var auth = express.basicAuth(function(user,pass) {
return 'user' === user && 'pass' === pass;
});
app.use('/static', auth, express.static(__dirname + '/static'));
app.use('/staticNoAuth', express.static(__dirname + '/static'));
app.listen(8082);
When I hit localhost:8082/admin
I get the username/password, then a 404. When I hit localhost:8082/adminNoAuth
it serves up the page.
I'm using Express 3.4.7 and node.js 0.10.22. Anybody have any ideas how I can do what I'm trying?
Cheers,
Brad.
app.use('/static', auth);
app.use('/static', express.static(__dirname + '/static'));
app.use('/staticNoAuth', express.static(__dirname + '/static'));