How can you serve multiple static directories using Express.js?

  • app.static('directory1'); app.static('directory2');
  • app.use(express.static('directory1')); app.use(express.static('directory2'));
  • app.static('directory1, directory2');
  • app.use(express.static(['directory1', 'directory2']));
To serve multiple static directories in Express.js, you should use the express.static middleware function multiple times with different directory paths. This allows you to specify and configure each static directory separately. The other options are not valid syntax for serving multiple static directories.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *