Open stevenvachon opened 8 years ago
Could also switch away from "mime" package to https://github.com/Hypercubed/mime-lookup
Hello?
Forget it.
I had the same issue, and solved it by:
var SERVER_PATH = './dist';
var SERVER_PORT = 8080;
function runServer() {
var file = new static.Server(SERVER_PATH);
require('http').createServer(function (request, response) {
request.addListener('end', function () {
// check if last part of address has extension, if not serve html
if (request.url.split('/').pop().indexOf('.') === -1) {
file.serveFile(request.url, 200, {'Content-Type': 'text/html'}, request, response);
} else {
file.serve(request, response);
}
}).resume();
}).listen(SERVER_PORT);
}
@cloudhead, file.serve(...)
should really have some way to manipulate headers :-)
Everything that this library does, st
does better.
PR #184 would allow something like this:
var file = new static.Server('./public');
require('http').createServer(function (request, response) {
request.addListener('end', function () {
response.setHeader('Content-Type', 'text/html') // explicitly override header here
file.serve(request, response);
}).resume();
}).listen(8080);
Files with no extension are served with content-type
"application/octet-stream"
due to https://www.npmjs.com/package/mime#mime-default-typeShouldn't they just be
undefined
?: