static() always uses text/html for MIME type

324 views
Skip to first unread message

Clint Harris

unread,
Aug 31, 2011, 12:13:33 PM8/31/11
to expre...@googlegroups.com
I'm using the "static" middleware that comes with Express to serve static files. Example: app.use(express.static(__dirname + '/public'));

The static files are being served, but the MIME type is always text/html, which causes problems with serving JavaScript, CSS, etc.

What's the best solution to this problem?

Thanks!

Clint Harris

unread,
Aug 31, 2011, 12:14:20 PM8/31/11
to expre...@googlegroups.com
FYI: Node 0.5.4, Express 2.4.3

David Ellis

unread,
Sep 1, 2011, 12:04:21 PM9/1/11
to Express
TJ will probably have a more exact solution for this exact problem,
but you probably ought to be gzipping your static content, anyways,
and gzippo (https://github.com/tomgallacher/gzippo) is a nice Express
middleware we use for our static content that doesn't really add
processing overhead (except when first creating the gzipped cache),
though it does add memory overhead (keeps the cache in memory rather
than putting it into memcached or the like).

We don't have any MIME type issues with it, so you can try that, and
if you still get the same MIME type for your files, that could be
indicating the problem is somewhere other than the static content
middleware.

David

On Aug 31, 12:14 pm, Clint Harris <clinthhar...@gmail.com> wrote:
> FYI: Node 0.5.4, Express 2.4.3
Reply all
Reply to author
Forward
0 new messages