Skip to content

Commit eb96645

Browse files
committed
disable og image generation
1 parent 8aa0cef commit eb96645

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/app/api/og-image/[...slug]/route.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const PUPPETEER_EXECUTABLE_PATH = process.env.PUPPETEER_EXECUTABLE_PATH;
2020
const OG_IMAGE_VALIDITY_PERIOD = revalidate * 1000;
2121
const PUPPETEER_ARGS = process.env.PUPPETEER_ARGS || "";
2222
const API_SLUG_PATTERN = /^\/api\/og-image((?:\/[.\w-]+)*)/;
23+
const IMAGE_GENERATION_ENABLED = false;
2324

2425
const imageGenerationPromises = new Map<string, Promise<NextResponse>>();
2526

@@ -189,14 +190,19 @@ const routeHandler: CustomMiddleware<[{ params: Promise<{ slug: string[] }> }]>
189190
console.info("Returning existing promise for", slug);
190191
return await result.previousPromise;
191192
case "not-found":
192-
return tryGenerateScreenshot(slug, payload);
193+
if (IMAGE_GENERATION_ENABLED) {
194+
return tryGenerateScreenshot(slug, payload);
195+
}
196+
// If image generation is disabled, return a 404
193197
case "image-invalid":
194198
console.error("OG image record has no URL", slug);
195199
return NextResponse.json({ message: "Image not found" }, { status: 404 });
196200
case "image-stale":
197-
// Update the image in the background but return the stale image
198-
console.info("Updating stale OG image for", slug, "from", result.image.updatedAt);
199-
tryGenerateScreenshot(slug, payload, result.image);
201+
if (IMAGE_GENERATION_ENABLED) {
202+
// Update the image in the background but return the stale image
203+
console.info("Updating stale OG image for", slug, "from", result.image.updatedAt);
204+
tryGenerateScreenshot(slug, payload, result.image);
205+
}
200206
// Fall through to redirect (deliberately omitted 'break')
201207
case "image-valid":
202208
return NextResponse.redirect(result.redirectUrl);

0 commit comments

Comments
 (0)