ftkvyn
ftkvyn

Reputation: 106

restify js default root page

I'm trying to write restful application using node.js restify. Here is my application's code :

var restify = require('restify');

var server = restify.createServer();

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

server.listen(3000, function() {
  console.log('%s listening at %s', server.name, server.url);
});

So, I can access index.html only by http://localhost:3000/index.html. I also expect to see my index.html page on the root url, http://localhost:3000/ but now i'm receiving there

{"code":"ResourceNotFound","message":"/"}

Upvotes: 2

Views: 366

Answers (1)

MForMarlon
MForMarlon

Reputation: 861

Give this a try:

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

Upvotes: 4

Related Questions