From f4ac246a09a2a5347f8a4fa0e299128986ad6957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Tue, 9 Jan 2024 14:05:32 +0100 Subject: [PATCH] Redirect to original image when cloudflare resize is returning an error (#90) --- src/app/~gitbook/image/route.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/~gitbook/image/route.ts b/src/app/~gitbook/image/route.ts index 232d4505c..4a13055cd 100644 --- a/src/app/~gitbook/image/route.ts +++ b/src/app/~gitbook/image/route.ts @@ -64,6 +64,10 @@ export async function GET(request: NextRequest) { try { const response = await resizeImage(url, options); + if (!response.ok) { + throw new Error('Failed to resize image'); + } + return response; } catch (error) { // Redirect to the original image if resizing fails