0

I need serve both http://localhost/users/list and http://localhost/users/list.html

server.get(/.*/, restify.serveStatic({
    directory: './public',
}));

This code only works if you specify the .html extension.

Almis
  • 3,684
  • 2
  • 28
  • 58

1 Answers1

0

I used serve-static which is middleware for expressjs and http and it worked.

var restify = require('restify');
var serveStatic = require('serve-static');

server = restify.createServer(options);

server.use(restify.acceptParser(server.acceptable));
server.use(restify.queryParser());
server.use(restify.bodyParser());
server.use(serveStatic('./public', { extensions: ['html'] }));

server.get(/.*/, restify.serveStatic({
    directory: './public',
    default: 'index.html',
}));

server.listen(80, function () {
    console.log('Server is running...')
});
Almis
  • 3,684
  • 2
  • 28
  • 58