I'm also going to drop my two cents.
The way I solved the same problem with serving static files is that I started using the Paperboy module, which is deprecated in favor of the submit module now.
Anyhoo, as I decided, it was a "grab" request before it went into my GET method and checked its path.
The way I “captured it” is as follows
self.preProcess(self, request, response);
and
preProcess: function onRequest(app, request, response){
If the path contained the STATICFILES directory, I would do a different file submission, otherwise I would go with the "html" -path. Below is //DO STUFF the preProcess() function
var path = urllib.parse(request.url).pathname; if(path.indexOf(settings.STATICFILES_DIR) != -1) { path = settings.STATICFILES_DIR; requestedFile = request.url.substring(request.url.lastIndexOf('/') + 1, request.url.length); return resolver.resolveResourceOr404(requestedFile, request, response); }
There may be a better way to do this, but it works like a charm for the things I need for this.
Using the Paperboy module, I then using the function resolver.resolveResourceOr404(); deliver the file this way
resolveResourceOr404 : function (filename, httpRequest, httpResponse) { var root = path.join(path.dirname(__filename), ''); paperboy.deliver(root, httpRequest, httpResponse) .error(function(e){ this.raise500(httpResponse); }) .otherwise(function(){ this.raise404(httpResponse); }); }