From 680a76530c778b53f63feaf6ad22a6eefa0943cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadeusz=20=E2=80=9Etadzik=E2=80=9D=20So=C5=9Bnierz?= Date: Thu, 5 Sep 2024 12:38:56 +0200 Subject: [PATCH] Don't set response headers if they're not present --- src/components/media-proxy.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/media-proxy.ts b/src/components/media-proxy.ts index 30c89668..2495d199 100644 --- a/src/components/media-proxy.ts +++ b/src/components/media-proxy.ts @@ -156,9 +156,15 @@ export class MediaProxy { }, (getRes) => { try { const { statusCode } = res; - res.setHeader('content-disposition', getRes.headers['content-disposition'] as string); - res.setHeader('content-type', getRes.headers['content-type'] as string); - res.setHeader('content-length', getRes.headers['content-length'] as string); + if (getRes.headers['content-disposition']) { + res.setHeader('content-disposition', getRes.headers['content-disposition']); + } + if (getRes.headers['content-type']) { + res.setHeader('content-type', getRes.headers['content-type']); + } + if (getRes.headers['content-length']) { + res.setHeader('content-length', getRes.headers['content-length']); + } res.status(statusCode); getRes.pipe(res); resolve();