summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-24 16:51:41 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-24 16:51:41 +1100
commit94669d79118d38ecfeef078b5233498bd9152c6b (patch)
tree7cc8adb9fabd712b56194d31499b851f1e6c226a
parentTestClient middleware will now add cache misses to file for generate:client s... (diff)
downloadserver-94669d79118d38ecfeef078b5233498bd9152c6b.tar.xz
Handle fetch errors in cdn external endpoint
-rw-r--r--src/cdn/routes/external.ts3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cdn/routes/external.ts b/src/cdn/routes/external.ts
index 32979a59..08e6b164 100644
--- a/src/cdn/routes/external.ts
+++ b/src/cdn/routes/external.ts
@@ -74,11 +74,14 @@ router.get("/resize/:url", async (req: Request, res: Response) => {
 	let buffer, response;
 	try {
 		response = await fetch(url, DEFAULT_FETCH_OPTIONS);
+		if (response.status !== 200) throw "e";		// lol super gross
 		buffer = await response.buffer();
 	} catch (e) {
 		throw new HTTPError("Couldn't fetch website");
 	}
 
+	if (buffer.length == 0) throw new HTTPError("Website response was empty.");
+
 	if (response.headers.get("content-type")?.indexOf("image") === -1) {
 		throw new HTTPError("Content type is not image.");
 	}