04 / 04

What happens when you inject @Res() into a handler — what side effect should you be aware of?

NestJS detects @Res() and switches to library-specific response mode, disabling automatic response serialization and interceptor result handling. You must manually call res.send() or res.json(). To avoid this, use @Res({ passthrough: true }) which keeps NestJS abstractions intact while still giving access to the response object.

When @Res() is detected in a handler, NestJS disables its built-in response handling pipeline. This means interceptors that transform the return value will no longer work, and you are responsible for sending the response manually.

Correct way to use @Res() without losing interceptors