Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raw body option usage issue #9901

Closed
3 of 15 tasks
obh opened this issue Jul 9, 2022 · 2 comments
Closed
3 of 15 tasks

raw body option usage issue #9901

obh opened this issue Jul 9, 2022 · 2 comments
Labels
needs triage This issue has not been looked into

Comments

@obh
Copy link

obh commented Jul 9, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Trying this doc to access the raw body for a request - https://docs.nestjs.com/faq/raw-body

But this only works for json requests and not form-encoded. This should be made clear in the docs.
The solution that i found was to just do this for form-encoded payload.

const rawBodyBuffer = (req, res, buf, encoding) => {
          if (buf && buf.length) {
               req.rawBody = buf.toString(encoding || 'utf8');
           }
};
app.use(bodyParser.urlencoded({verify: rawBodyBuffer, extended: true }));

Minimum reproduction code

https://github.com/obh/nest-test

Steps to reproduce

No response

Expected behavior

ideally you accept both json and form-encoded requests to work in the same way.

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

9.0.0

Packages versions

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@obh obh added the needs triage This issue has not been looked into label Jul 9, 2022
@kamilmysliwiec
Copy link
Member

@tolgap could you look into that? 🙌

@kamilmysliwiec
Copy link
Member

Let's track this here #9926

@nestjs nestjs locked and limited conversation to collaborators Jul 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

2 participants