Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new airtable cdn domain to allowlist #150

Merged
merged 2 commits into from
Nov 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions server/src/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down Expand Up @@ -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";
}
Expand All @@ -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

Expand All @@ -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();
Expand Down