cloudhead / node-static

rfc 2616 compliant HTTP static-file server module, with built-in caching.
MIT License
2.17k stars 245 forks source link

Hidden files/folders #211

Open brettz9 opened 6 years ago

brettz9 commented 6 years ago

Is there any means, whether through a generic filter by file name, or by config specifically targeting hidden files/folders, that one may prevent/enable hidden files from being served? Thanks!

vovchisko commented 6 years ago

Let's say "sometimes" you don't want to serve something.

require('http').createServer(function (request, response) {
    request.addListener('end', function () {
        // Serve files! ... or not?
        if(request.url.includes('mom')) {
             nodeStatic.serveFile('/nothing-about-mom.html', 404, {}, request, response);
         }
         nodeStatic.serve(request, response);
    }).resume();
}).listen(8080);
brettz9 commented 6 years ago

Yes, sure, thanks--I should have mentioned though that I was hoping for a CLI option...

vovchisko commented 6 years ago

@brettz9 at least I don't see anything here https://github.com/cloudhead/node-static/blob/master/bin/cli.js

brettz9 commented 5 years ago

This would be particularly helpful for an easy means to set up production static servers on the root of one's repository without fear of exposing .git.