Skip to content

Commit 2e2ccc6

Browse files
committed
redo change
1 parent 82cc79d commit 2e2ccc6

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/core.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,8 +1139,27 @@ function applyHeadersMut(targetHeaders: Headers, newHeaders: Headers): void {
11391139
}
11401140

11411141
export function debug(action: string, ...args: any[]) {
1142+
const sensitiveHeaders = ["authorization", "api-key"];
11421143
if (typeof process !== 'undefined' && process?.env?.['DEBUG'] === 'true') {
1143-
console.log(`OpenAI:DEBUG:${action}`, ...args);
1144+
for (const arg of args) {
1145+
if (!arg) {
1146+
break;
1147+
}
1148+
// Check for sensitive headers in request body "headers"
1149+
if (arg["headers"]) {
1150+
for (const header in arg["headers"]){
1151+
if (sensitiveHeaders.includes(header.toLowerCase())){
1152+
arg["headers"][header] = "REDACTED";
1153+
}
1154+
}
1155+
}
1156+
// Check for sensitive headers in headers object
1157+
for (const header in arg){
1158+
if (sensitiveHeaders.includes(header.toLowerCase())){
1159+
arg[header] = "REDACTED";
1160+
}
1161+
}
1162+
}
11441163
}
11451164
}
11461165

0 commit comments

Comments
 (0)