سؤال

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 ?

هل كانت مفيدة؟

المحلول

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

server.get(/.*/, restify.serveStatic({
  directory: __dirname,
  default: "index.html"
}));
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top