I should preface this by the fact I am new to NodeJS, and more generally to all the coding your own web server business, so please bear with me.
What I'm trying to achieve basically is replicating Apache's alias mechanism. I should simply be able to configure a list of aliases and their corresponding path in a configuration file, then have Node serve the right resource depending on the request.
To achieve this I singled out two middleware to use on top of Connect: static and route. Route is mostly working as intended, but I have a problem grasping how static works. Specifically, my question right now would be : Is it possible to define multiple "statics" to use with connect and then choose which one you want to actually serve files through after receiving a request?
Thanks
You can define multiple static to use with connect.
app.use(express.static(__dirname + '/public1'));
app.use(express.static(__dirname + '/public2'));
The connect middleware will check if the file exists in the first directory and if not found it will check the next one.
But static means static you shouldn't use with req.
If you wish to serve files based on the req then you should set-up a dynamic route that can serve content based on the request.