IDebug is experimental. Prefer enabling only in development.
GuidesMiddleware order

Middleware order

const app = express();
 
app.use(express.json()); // 1 body parsers
app.use(cookieParser()); // 1b optional
 
app.use(IDebug.middleware()); // 2 tracing + ALS
 
// 3 routes
app.get('/api/...', handler);
 
app.use(IDebug.ui()); // 4 inspector (path-gated)
 
app.use(errorHandler); // 5 errors after routes

Why parsers first?

The initial req event snapshots body, query, params, and cookies at middleware entry. If JSON parsing runs later, body will be empty on that snapshot (later reqModified may still show writes).

Why UI last (or anywhere after parsers)?

ui() only handles paths under basePath and does not need to sit before routes, but it must not be blocked by a catch-all that never calls next().

NestJS

IDebugModule.forRoot registers middleware for application routes and serves UI for {basePath}/*. Prefer enabling early in module imports so global interceptors/decorators see the same store.

Skipping self-noise

Traffic to {basePath} (the inspector itself) does not create debug sessions, so refreshing the UI will not flood the session list.