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

[BUG] nestjs-pino fails to log HTTP requests with global prefix #1849

Open
4 tasks done
andreymyssak opened this issue Feb 11, 2024 · 3 comments
Open
4 tasks done

[BUG] nestjs-pino fails to log HTTP requests with global prefix #1849

andreymyssak opened this issue Feb 11, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@andreymyssak
Copy link

andreymyssak commented Feb 11, 2024

What is the current behavior?
After setting a global prefix app.setGlobalPrefix('/api') in main.ts, nestjs-pino unexpectedly stops logging HTTP requests. However, the logger's other functionalities remain operational.

What is the expected behavior?
nestjs-pino should consistently log HTTP requests even when a global prefix is applied.

Please provide minimal example repo, not code snippet. Without example repo this issue will be closed.

  1. Clone the repository https://github.com/andreymyssak/nestjs-pino-global-prefix-issue and install dependencies using npm i.
  2. Start the application in development mode with npm run start:dev.
  3. Make a request to localhost:3000/api using a browser or Postman.
  4. Observe that no logs are shown in the terminal for the HTTP request.

Please mention other relevant information such as Node.js version and Operating System.
Node.js Version: v18.15.0
Operating System: MacOS Sonoma Version 14.2.1 (23C71)

@andreymyssak andreymyssak added the bug Something isn't working label Feb 11, 2024
@iamolegga
Copy link
Owner

Thanks for reporting, will get back to this as soon as possible

@keshav-c
Copy link

keshav-c commented Jun 9, 2024

Btw I just tried this on my machine locally, and I can see the request logs just fine. However, on checking OP's sample app I also face the same issue as them. I am using nestjs v10.0.0 but I couldn't solve the issue even on upgrading nestjs-pino and pino-http to the latest versions

SCR-20240610-bzkp

@jokj624
Copy link

jokj624 commented Jun 12, 2024

I found something interesting during the test.
When I clone example repository gave me as an example and tested it, I also face the same issue.

However, if I request to url added another string after prefix like '/api/', '/api/hello', request log works fine.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants