#When i use rawBody: true, i cant get data

13 messages · Page 1 of 1 (latest)

static radish
#
async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule, {
    bodyParser: false,
    rawBody: true,
  });
  await app.listen(5000);
}
bootstrap();
@Post()
  create(@Req() req: RawBodyRequest<Request>) {
    const raw = req.rawBody; // returns a `Buffer`.
    console.log(raw); // it be undefined
  }

When i need to get EUC-KR Encoding Data, i need to use bodyparser: false, rawBody: true
But I can't read req.rawBody data, it will be undefind.

My code is wrong?

i use this version
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/platform-express": "^9.0.0",

edgy helm
#

What version of Nest are you using?

static radish
#

@edgy helm Something wrong?

edgy helm
#

Nope. Just wondering from your other question.

static radish
#

Ok.

brisk crag
#

Why is bodyParser false here?

static radish
static radish
#

with iconv and Buffer.toString() got same value,
-> <Buffer 6e 61 6d 65 3d 25 42 35 25 42 46 25 42 46 25 45 43>, name=%B5%BF%BF%EC

brisk crag
#

Might need to toString('utf-8') it

static radish
#

const raw = req.rawBody; // returns a Buffer.
const utf8Raw = raw.toString('utf-8');
console.log(utf8Raw);

hmm.. i got same value damn..

brisk crag
#

Might be a different encoding? Not sure to be honest