You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/faq/raw-body.md
+32-4Lines changed: 32 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,16 +42,31 @@ By default, only `json` and `urlencoded` parsers are registered. If you want to
42
42
For example, to register a `text` parser, you can use the following code:
43
43
44
44
```typescript
45
-
app.useBodyParser('text')
45
+
app.useBodyParser('text');
46
46
```
47
47
48
+
> warning **Warning** Ensure that you are providing the correct application type to the `NestFactory.create` call. For Express applications, the correct type is `NestExpressApplication`. Otherwise the `.useBodyParser` method will not be found.
49
+
50
+
#### Body parser size limit
51
+
52
+
If your application needs to parse a body larger than the default `100kb` of Express, use the following:
53
+
54
+
```typescript
55
+
app.useBodyParser('json', { limit: '10mb' });
56
+
```
57
+
58
+
The `.useBodyParser` method will respect the `rawBody` option that is passed in the application options.
59
+
48
60
#### Use with Fastify
49
61
50
62
First enable the option when creating your Nest Fastify application:
@@ -87,5 +102,18 @@ By default, only `application/json` and `application/x-www-form-urlencoded` pars
87
102
For example, to register a `text/plain` parser, you can use the following code:
88
103
89
104
```typescript
90
-
app.useBodyParser('text/plain')
105
+
app.useBodyParser('text/plain');
91
106
```
107
+
108
+
> warning **Warning** Ensure that you are providing the correct application type to the `NestFactory.create` call. For Fastify applications, the correct type is `NestFastifyApplication`. Otherwise the `.useBodyParser` method will not be found.
109
+
110
+
#### Body parser size limit
111
+
112
+
If your application needs to parse a body larger than the default 1MiB of Fastify, use the following:
0 commit comments