Skip to content

Instantly share code, notes, and snippets.

@cmstead
Created December 13, 2015 19:45
Show Gist options
  • Select an option

  • Save cmstead/1cb72799dfd5505eb484 to your computer and use it in GitHub Desktop.

Select an option

Save cmstead/1cb72799dfd5505eb484 to your computer and use it in GitHub Desktop.
Express serving static files from a directory
// Serving static files in a named directory, served from the root path
app.use(express.static('path/to/static/files')); // This will pick up deep references within named directory
// http://localhost:3000/js/foo.js <- foo.js lives in path/to/static/files/js/foo.js
// Serving files from a virtual directory
app.use('/blar', express.static('path/to/static/files'));
// http://localhost:3000/blar/js/foo.js <- foo.js lives in path/to/static/files/js/foo.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment