Hide refresh_token/client_secret/naIdToken fields in logs, ignore Cloudflare HTML errors

This commit is contained in:
Samuel Elliott
2025-07-25 19:05:36 +01:00
parent 4452947187
commit 0f0f666ea6
2 changed files with 12 additions and 3 deletions

View File

@@ -27,6 +27,15 @@ export class ErrorResponse<T = unknown> extends Error {
Object.defineProperty(this, ErrorResponseSymbol, {enumerable: false, value: ErrorResponseSymbol});
if (response.status === 502 &&
response.headers.get('Server') === 'cloudflare' &&
response.headers.get('Content-Type')?.match(/^text\/html(;|$)/)
) {
// Cloudflare returns it's own HTML error page for HTTP 502 errors
// Logging this isn't helpful so just discard it
body = 'Bad Gateway\n';
}
if (body instanceof ArrayBuffer) {
body = (new TextDecoder()).decode(body);
}