Courses / Node.js
11. app.use() for mounting middleware
Attach middleware or routers to an application or path prefix using app.use().
1 min read Chapter 11 of 48
JavaScript
app.use() for mounting middleware
A way to attach middleware functions or routers to an Express app or to a path prefix so they run for matching requests.
"I want logging, auth, or a sub-app to run automatically for a bunch of routes without repeating code."
app.use() registers one or more middleware or a router on the application (or a path) so Express calls them in order for matching requests.
"I want logging, auth, or a sub-app to run automatically for a bunch of routes without repeating code."
app.use() registers one or more middleware or a router on the application (or a path) so Express calls them in order for matching requests.