mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-23 09:17:55 +00:00
Filter out sensitive fields from request and response bodies for logging
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user