Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NestJS HTTPS empty @POST() body

Im using NestJS via HTTPS.

import { NestFactory } from '@nestjs/core';
import { fstat } from 'fs';
import { AppModule } from './app.module';
import {readFileSync} from 'fs'
async function bootstrap() {
  const httpsOptions = {
    key:readFileSync('tsl/private-key.pem'),
    cert:readFileSync('tsl/public-cert.pem')
  }
  const app = await NestFactory.create(AppModule,{httpsOptions});
  await app.listen(3000);
}

bootstrap();

I try to get simple POST request:

 @Post()
   test(@Body() body){
     console.log(body);
  }

But output is always {}

POSTMAN: postman

I readed that nestjs cant parse data correctly. How can i fix that?

like image 389
vantaqada Avatar asked May 10 '26 08:05

vantaqada


1 Answers

Your postman request needs to be set to raw and JSON, not raw and Text

like image 126
Jay McDoniel Avatar answered May 12 '26 21:05

Jay McDoniel