Permalink
Browse files

Add 404s to static file serving

  • Loading branch information...
1 parent 8cde35e commit 9e2f65f39918a8ce17d5f1ad6cb73d18148327b9 @drewzboto drewzboto committed Dec 15, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 tasks/server.js
View
@@ -109,15 +109,23 @@ module.exports = function(grunt) {
// If there are query parameters, remove them.
filename = filename.split("?")[0];
- res.sendfile(path.join(options.folders[key] + filename));
+ res.sendfile(path.join(options.folders[key] + filename), {}, function(err) {
+ if (err) {
+ res.send(404);
+ }
+ });
});
});
// Map static files.
if (_.isObject(options.files)) {
Object.keys(options.files).sort().reverse().forEach(function(key) {
site.get(root + key, function(req, res) {
- return res.sendfile(options.files[key]);
+ return res.sendfile(options.files[key], {}, function(err) {
+ if (err) {
+ res.send(404);
+ }
+ });
});
});
}

0 comments on commit 9e2f65f

Please sign in to comment.