nestjs-pino icon indicating copy to clipboard operation
nestjs-pino copied to clipboard

[BUG] NestJS with Fastify : response headers are empty

Open remija opened this issue 2 years ago • 3 comments

[X] I've read the docs of nestjs-pino

[X] I've read the docs of pino

[X] I couldn't find the same open issue of nestjs-pino

What is the current behavior?

HTTP log messages return an empty Response Headers object when using the library as part of a NestJS application with the Fastify platform, unlike the default Express platform.

Example:

  • NestJS with Fastify {"level":30,"time":1647270615012,"pid":46872,"hostname":"MacBook-Pro.local","req":{"id":"req-2","method":"POST","url":"/v0/test-post","query":{},"headers":{"content-type":"application/json","user-agent":"PostmanRuntime/7.28.4","accept":"/","postman-token":"cc8db335-488b-4741-966a-87b09cb96951","host":"localhost:3000","accept-encoding":"gzip, deflate, br","connection":"keep-alive","content-length":"69"},"remoteAddress":"127.0.0.1","remotePort":51821},"res":{"statusCode":201,"headers":{}},"responseTime":7,"msg":"request completed"}

  • NestJS with Express {"level":30,"time":1647270754658,"pid":46900,"hostname":"MacBook-Pro.local","req":{"id":1,"method":"POST","url":"/v0/test-post","query":{},"params":{"0":"v0/test-post/remi"},"headers":{"content-type":"application/json","user-agent":"PostmanRuntime/7.28.4","accept":"/","postman-token":"7803653a-bbd3-4e7b-8733-37d59bfc0276","host":"localhost:3000","accept-encoding":"gzip, deflate, br","connection":"keep-alive","content-length":"69"},"remoteAddress":"127.0.0.1","remotePort":51829},"res":{"statusCode":201,"headers":{"x-powered-by":"Express","content-type":"application/json; charset=utf-8","content-length":"30","etag":"W/"1e-ZljF/Nt5uArBAuXc8XriunP0mGg""}},"responseTime":5,"msg":"request completed"}

What is the expected behavior?

The Response Headers must be filled in NestJS with Fastify case.

Please provide minimal example repo. Without it this issue will be closed

Please mention other relevant information such as Node.js version and Operating System.

NodeJS 14.18.1 NestJS 8.4.1 (latest, same result with other 8 versions) nest-pino 2.5.0

Otherwise very good work, thank you ;)

remija avatar Mar 14 '22 15:03 remija

+1

antonbarada avatar Mar 30 '22 22:03 antonbarada

req.user not work too.

jongomes avatar Oct 25 '23 19:10 jongomes

+1

johaven avatar Nov 25 '23 16:11 johaven