summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-07-31 17:54:09 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-07-31 17:54:09 +1000
commitc2d388e16dd8d6a74b3b2f64352c6a42f8c0ea42 (patch)
tree21fe2b7f71d2cf9bf0890e38a9d94bceab82512e
parentMerge branch 'slowcord' of github.com:MaddyUnderStars/fosscord-server into sl... (diff)
downloadserver-c2d388e16dd8d6a74b3b2f64352c6a42f8c0ea42.tar.xz
Untested gif resize support in cdn
-rw-r--r--cdn/src/routes/external.ts7
1 files 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);
 });