I don't know if this is a limitation to node-static
or is it a bug in my code, but I can't seem to get it to serve files above or beyond the current directory. My current directory structure is this:
project
public
...public stuff here...
system
core
server.js
server.js
lives in core
directory, making the path to public
as ../../public
- but this code won't run. It returns a 404.
staticServer = new (static.Server)('../../public');
webServer = http.createServer(function (request, response) {
staticServer.serve(request,response);
})
webServer.listen(appServerConfig.port, appServerConfig.address);
However, if I change the structure to make the public folder live beside server.js
and change the code accordingly, it works:
project
system
core
server.js
public
...public stuff here...
staticServer = new (static.Server)('./public');
webServer = http.createServer(function (request, response) {
staticServer.serve(request,response);
})
webServer.listen(appServerConfig.port, appServerConfig.address);
Why is this so?