Skip to content

Commit 2e9e6ce

Browse files
Merge pull request #1820 from peterfication/add-hint-to-global-middleware
docs(middlewares): Add hint for global middlewares and DI
2 parents f7cbce7 + 4222e99 commit 2e9e6ce

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

content/middlewares.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,5 @@ const app = await NestFactory.create(AppModule);
241241
app.use(logger);
242242
await app.listen(3000);
243243
```
244+
245+
> info **Hint** Accessing the DI container in a global middleware is not possible. You can use a [functional middleware](middleware#functional-middleware) instead when using `app.use()`. Alternatively, you can use a class middleware and consume it with `.forRoutes('*')` within the `AppModule` (or any other module).

0 commit comments

Comments
 (0)