Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add 404s to static file serving

  • Loading branch information...
commit 9e2f65f39918a8ce17d5f1ad6cb73d18148327b9 1 parent 8cde35e
@drewzboto drewzboto authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 tasks/server.js
View
12 tasks/server.js
@@ -109,7 +109,11 @@ 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);
+ }
+ });
});
});
@@ -117,7 +121,11 @@ module.exports = function(grunt) {
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);
+ }
+ });
});
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.