This is not possible for a single intermediate injection, but you can add static middleware several times:
app.configure('development', function(){ app.use(express.static(__dirname + '/public1')); app.use(express.static(__dirname + '/public2')); });
Explanation
See connect / lib / middleware / static.js # 143 :
path = normalize(join(root, path));
There is options.root - the static root that you define in the call to express.static or connect.static , and path is the request path.
See more at connect / lib / middleware / static.js # 154 :
fs.stat(path, function(err, stat){ // ignore ENOENT if (err) { if (fn) return fn(err); return ('ENOENT' == err.code || 'ENAMETOOLONG' == err.code) ? next() : next(err);
The path is checked only once, and if the file is not found, the request proceeds to the next middleware.
Update for connect 2.x
Code links are not relevant for Connect 2.x, but using static middleware is still possible, as before.
Phillip Kovalev May 12 '11 at 10:23 a.m. 2011-12-12 10:23
source share