Is it possible? I would like to set up two different directories to serve static files. Let's say /public and /mnt
You can also set the path that static files will be served to the web from by specifying an additional (first) parameter to use()
like so:
app.use("/public", express.static(__dirname + "/public")); app.use("/public2", express.static(__dirname + "/public2"));
That way you get two different directories on the web that mirror your local directories, not one url path that fails over between two local directories.
In other words the URL pattern:
http://your.server.com/public/*
Serves files from the local directory public
while:
http://your.server.com/public2/*
Serves files from the local directory public2
.
BTW this is also useful if you don't want static to serve the files from the root of your server but rather from a more qualified path.
HTH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With