Courses / Node.js
15. Serving static files with express.static()
Mount a directory to serve static assets using express.static middleware.
1 min read Chapter 15 of 48
JavaScript
Serving static files with express.static()
Middleware that serves files (HTML, CSS, JS, images) from a directory so Express sends them directly to the client.
"I don't want to write route handlers for every image, script, or CSS file."
express.static is middleware you mount at a path to serve files from a filesystem directory; requests matching files are returned automatically.
"I don't want to write route handlers for every image, script, or CSS file."
express.static is middleware you mount at a path to serve files from a filesystem directory; requests matching files are returned automatically.