To set up two different static directories in Node.js Express framework, we call express.static
.
For instance, we write
app.use("/public", express.static(__dirname + "/public"));
app.use("/public2", express.static(__dirname + "/public2"));
to call express.static
to return 2 middlewares toi server the /public and /public2 folders as static directories.
And then we call app.use
to use the middlewares to make the folders available via the /public and /public2 URLs.