0

I have a restify server with node.js I use to make some development and tests and to do so, I use serveStatic.

I wonder why I cannot use the following configuration without getting 403 errors:

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

Although if I make a link to my current dir:

ln -s . serverDir

This will work:

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

What is the reason for this ? Security ? Bug ? Software or network limitation ?

Is there something I should know or read about serving static files ?

lauhub
  • 894
  • 1
  • 15
  • 27

1 Answers1

2

Can you user __dirname instead of '.' to indicate the current directory?

server.get(/.*/, restify.serveStatic({
  directory: __dirname,
  default: "index.html"
}));
Sriharsha
  • 2,373
  • 1
  • 16
  • 20
  • '.' is not the recommended way to provide the current directory. I guess restify is not resolving the path properly. – Sriharsha Dec 05 '13 at 13:28
  • I also tried "./" and it did not work. So it's strange to me that "./serverDir" works – lauhub Dec 05 '13 at 14:00
  • 1
    Problem is @https://github.com/mcavage/node-restify/blob/master/lib/plugins/static.js#L102, the opts.directory is not resolved, only normalized hence the error. – Sriharsha Dec 05 '13 at 15:09