From ead3a94551e7e0a994f71716265facad13f1351e Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Tue, 13 Jul 2021 14:22:39 +0100 Subject: [PATCH 1/3] fix: disable png palette --- src/lib/templates/imageFunction.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/templates/imageFunction.js b/src/lib/templates/imageFunction.js index d2cbb50e65..a7b542fc40 100644 --- a/src/lib/templates/imageFunction.js +++ b/src/lib/templates/imageFunction.js @@ -122,8 +122,8 @@ const handler = async (event) => { // make it return that format. const { info, data: imageBuffer } = await sharp(bufferData) .rotate() - .jpeg({ quality, mozjpeg: true, force: ext === 'jpg' }) - .png({ quality, palette: true, force: ext === 'png' }) + .jpeg({ quality, force: ext === 'jpg' }) + .png({ quality, force: ext === 'png' }) .webp({ quality, force: ext === 'webp' }) .avif({ quality, force: ext === 'avif' }) .resize(width, null, { withoutEnlargement: true }) From baa4586e57dfda4b17bc787e276a1bf16063b4f8 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Tue, 13 Jul 2021 14:25:38 +0100 Subject: [PATCH 2/3] fix: remove redirect --- src/lib/templates/imageFunction.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/lib/templates/imageFunction.js b/src/lib/templates/imageFunction.js index a7b542fc40..5a14dd54cf 100644 --- a/src/lib/templates/imageFunction.js +++ b/src/lib/templates/imageFunction.js @@ -84,20 +84,6 @@ const handler = async (event) => { return { statusCode: 400, body: 'Source does not appear to be an image' } } - const dimensions = imageSize(bufferData) - - if (width > dimensions.width) { - // We won't upsize images, and to avoid downloading the same size multiple times, - // we redirect to the largest available size - const Location = `/nextimg/${url}/${dimensions.width}/${q}` - return { - statusCode: 302, - headers: { - Location, - }, - } - } - let { ext } = type // For unsupported formats (gif, svg) we redirect to the original From 82ce1ec5edf2b57690d9b74413aa3c62bcc15ade Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Tue, 13 Jul 2021 15:27:44 +0100 Subject: [PATCH 3/3] fix: image config --- src/lib/templates/imageFunction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/templates/imageFunction.js b/src/lib/templates/imageFunction.js index 5a14dd54cf..1e445295a9 100644 --- a/src/lib/templates/imageFunction.js +++ b/src/lib/templates/imageFunction.js @@ -48,7 +48,7 @@ const handler = async (event) => { } else { isRemoteImage = true // Remote images need to be in the allowlist - let allowedDomains = config.images?.domains || [] + let allowedDomains = config.domains || [] if (process.env.NEXT_IMAGE_ALLOWED_DOMAINS) { console.log('Combining `NEXT_IMAGE_ALLOWED_DOMAINS` with any domains found in `next.config.js`')