Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no file extension, application/octet-stream #169

Open
stevenvachon opened this issue Oct 13, 2015 · 7 comments
Open

no file extension, application/octet-stream #169

stevenvachon opened this issue Oct 13, 2015 · 7 comments

Comments

@stevenvachon
Copy link

Files with no extension are served with content-type "application/octet-stream" due to https://www.npmjs.com/package/mime#mime-default-type

Shouldn't they just be undefined?:

mime.default_type = undefined
@stevenvachon
Copy link
Author

Could also switch away from "mime" package to https://github.com/Hypercubed/mime-lookup

@stevenvachon
Copy link
Author

Hello?

@stevenvachon
Copy link
Author

Forget it.

Switching to st fixed this issue.

@CezaryDanielNowak
Copy link

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);
}

@CezaryDanielNowak
Copy link

@cloudhead, file.serve(...) should really have some way to manipulate headers :-)

@stevenvachon
Copy link
Author

Everything that this library does, st does better.

@leviwheatcroft
Copy link

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants