From 61c9069558b6bf89989f795047c4d836ccba0b60 Mon Sep 17 00:00:00 2001 From: Jordan Medrano Date: Tue, 8 Nov 2022 13:11:13 -0600 Subject: [PATCH 1/2] add new airtable cdn domain to allowlist --- server/src/images.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/images.js b/server/src/images.js index 925a6c78..5bf1726d 100644 --- a/server/src/images.js +++ b/server/src/images.js @@ -148,7 +148,7 @@ module.exports = ({ app, cors, Cache, corsHandle }) => { const originalFileType = dots[dots.length - 1]; // last . (now works with .svg.png) const filename = parts[4] + "." + originalFileType; - if (!["dl.airtable.com", "media.slmn.io"].some(domain => domain === parts[2])) { + if (!["dl.airtable.com", "media.slmn.io", "v5.airtableusercontent.com"].some(domain => domain === parts[2])) { return res.status(400).send("Domain not whitelisted"); } From bdede3d18b02aae661344fa20447bd91d2d853d9 Mon Sep 17 00:00:00 2001 From: Solomon Cammack Date: Tue, 8 Nov 2022 14:12:07 -0800 Subject: [PATCH 2/2] Temporarily let more image requests through --- server/src/images.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/src/images.js b/server/src/images.js index 5bf1726d..951df724 100644 --- a/server/src/images.js +++ b/server/src/images.js @@ -194,7 +194,7 @@ module.exports = ({ app, cors, Cache, corsHandle }) => { }; } - if (["svg", "gif"].includes(originalFileType)) { + if (!size /*["svg", "gif"].includes(originalFileType)*/) { // TODO: load image first then detect filetype // just do orig if svg size = "orig"; } @@ -205,7 +205,11 @@ module.exports = ({ app, cors, Cache, corsHandle }) => { let imagePath = await getImage(filename, size); - if (imagePath) return res.sendFile(imagePath); + if (imagePath) { + // let metaFileType = (await sharp(imagePath).metadata())?.format; + // console.log({metaFileType}); + return res.sendFile(imagePath); + } console.log("[image]", `no file for ${originalFilename} @ ${size}`); // no image @@ -222,6 +226,9 @@ module.exports = ({ app, cors, Cache, corsHandle }) => { if (size === "orig") return res.sendFile(orig); } + // let metaFileType = (await sharp(orig).metadata())?.format; + // console.log({metaFileType}); + // resize time! // console.log("[image]", `resizing ${originalFilename} @ ${size}`); const t = Date.now();