Skip to content

Commit

Permalink
Docs: rateLimitFactory example for ERR_ERL_CREATED_IN_REQUEST_HANDLER
Browse files Browse the repository at this point in the history
Relates to #453
  • Loading branch information
nfriedly committed Apr 8, 2024
1 parent e0b1032 commit 562d5fc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/reference/error-codes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,18 @@ app.use(rateLimit({
}))
```
If using a factory function to create express-rate-limit instances, ensure that
it is called at app initialization, not in response to each request:
```diff
function rateLimitFactory() {
return rateLimit({/*...*/});
}

- app.use(rateLimitFactory); // Broken
+ app.use(rateLimitFactory()); // Works
```
Set `validate: {creationStack: false}` in the options to disable the check.
## Warnings
Expand Down

0 comments on commit 562d5fc

Please sign in to comment.