From 2ff03120875887c0bee51d51e264810d3a3bfe34 Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Tue, 2 Jul 2024 19:39:31 +0300 Subject: [PATCH] Filter out sensitive fields from request and response bodies for logging --- src/interceptors/logging.interceptor.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/interceptors/logging.interceptor.ts b/src/interceptors/logging.interceptor.ts index e74f4c2..9e06186 100644 --- a/src/interceptors/logging.interceptor.ts +++ b/src/interceptors/logging.interceptor.ts @@ -15,7 +15,7 @@ export class LoggingInterceptor implements NestInterceptor { return next.handle().pipe( map((response) => { - // Filter out sensitive fields from the request body + // Filter out sensitive fields from the request body for logging const filteredRequestBody = this.filterSensitiveFields(body); console.log( '-------------------------------------------------------------------', @@ -28,10 +28,10 @@ export class LoggingInterceptor implements NestInterceptor { ) { console.log(`Request Body: ${JSON.stringify(filteredRequestBody)}`); } - // Filter out sensitive fields from the response + // Filter out sensitive fields from the response for logging const filteredResponse = this.filterSensitiveFields(response); console.log(`Response: ${JSON.stringify(filteredResponse)}`); - return filteredResponse; + return response; // Return the actual response unmodified }), catchError((error) => { // Do not log anything if there is an error