Skip to content

Instantly share code, notes, and snippets.

@EvanHahn
Created September 5, 2014 19:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvanHahn/38f08f40a23e0cb9f4b0 to your computer and use it in GitHub Desktop.
Save EvanHahn/38f08f40a23e0cb9f4b0 to your computer and use it in GitHub Desktop.
Disabling some headers set by Express's static middleware.
var express = require("express");
var onHeaders = require("on-headers");
var path = require("path");
var app = express();
// ...
app.use(function(req, res, next) {
onHeaders(res, function() {
res.removeHeader("Accept-Ranges");
});
next();
});
var myStaticPath = path.resolve(__dirname, "static");
app.use(express.static(myStaticPath));
// ...
app.listen(1337);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment