Permalink
Browse files

Added mime-type guessing for static files

  • Loading branch information...
1 parent be49f73 commit aefc3d3a38af28b7ec9605d6476b1166c25c02d8 @jhnns jhnns committed Mar 7, 2014
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/Server.js
View
@@ -4,6 +4,7 @@ var webpackDevMiddleware = require("webpack-dev-middleware");
var express = require("express");
var socketio = require("socket.io");
var StreamCache = require("stream-cache");
+var mime = require("mime");
function Server(compiler, options) {
@@ -80,9 +81,10 @@ Server.prototype.serveContent = function(req, res, next) {
function checkFile(filename) {
try {
return this.middleware.fileSystem.statSync(filename).isFile();
- } catch(e) { return false };
+ } catch(e) { return false; }
}
if(!err && stat.isFile()) {
+ res.setHeader("Content-Type", mime.lookup(_path));
fs.createReadStream(target).pipe(res);
} else if(!err && stat.isDirectory()) {
res.writeHead(302, {

0 comments on commit aefc3d3

Please sign in to comment.