Express

Global middleware applies expensive operations to all routes

warning
performanceUpdated Feb 8, 2026(via Exa)
Technologies:
How to detect:

Applying expensive middleware (body parsing, authentication) globally with app.use() causes unnecessary processing for routes that don't need it, including static files and health checks.

Recommended action:

Scope middleware to specific route prefixes or individual routes. Apply bodyParser.json() only to /api routes. Exclude health checks and static assets from auth and body parsing.