From c2d388e16dd8d6a74b3b2f64352c6a42f8c0ea42 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sun, 31 Jul 2022 17:54:09 +1000 Subject: Untested gif resize support in cdn --- cdn/src/routes/external.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cdn/src/routes/external.ts b/cdn/src/routes/external.ts index 577c38ec..fc12c017 100644 --- a/cdn/src/routes/external.ts +++ b/cdn/src/routes/external.ts @@ -68,9 +68,9 @@ router.get("/resize/:url", async (req: Request, res: Response) => { const h = Math.min(parseInt(height as string), resizeHeightMax ?? 100); if (w < 1 || h < 1) throw new HTTPError("Width and height must be greater than 0"); - let buffer; + let buffer, response; try { - const response = await fetch(url, DEFAULT_FETCH_OPTIONS); + response = await fetch(url, DEFAULT_FETCH_OPTIONS); buffer = await response.buffer(); } catch (e) { @@ -81,11 +81,10 @@ router.get("/resize/:url", async (req: Request, res: Response) => { .resize(parseInt(width as string), parseInt(height as string), { fit: "inside", }) - .png() .toBuffer(); res.setHeader("Content-Disposition", "attachment"); - res.setHeader("Content-Type", "image/png"); + res.setHeader("Content-Type", response.headers.get("content-type") ?? "image/png"); return res.end(resizedBuffer); }); -- cgit 1.4.1