Skip to content

Full Toolkit for Next-Level Domain Analysis

Move Open Graph images off the Edge Runtime 🖼️🪂 (#129)

Felix Wotschofsky66d9918e7f89
diff --git a/app/(landing)/opengraph-image.tsx b/app/(landing)/opengraph-image.tsx
index 3ec807b..5451a05 100644
--- a/app/(landing)/opengraph-image.tsx
+++ b/app/(landing)/opengraph-image.tsx
@@ -1,6 +1,8 @@
+import { readFile } from 'node:fs/promises';
+import { join } from 'node:path';
+
import { ImageResponse } from 'next/og';
-export const runtime = 'edge';
export const contentType = 'image/png';
const fetchArrayBuffer = async (url: string | URL) =>
@@ -14,7 +16,7 @@ export const handler = async () => {
fetchArrayBuffer(
'https://fonts.bunny.net/inter/files/inter-latin-700-normal.woff',
),
- fetchArrayBuffer(new URL('@/assets/globe.png', import.meta.url)),
+ readFile(join(process.cwd(), 'assets/globe.png')),
]);
return new ImageResponse(
@@ -150,7 +152,7 @@ export const handler = async () => {
{/* eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text */}
<img
- src={`data:image/png;base64,${Buffer.from(globeImage).toString('base64')}`}
+ src={`data:image/png;base64,${globeImage.toString('base64')}`}
width={1000}
style={{
position: 'absolute',
diff --git a/app/lookup/[domain]/(dns)/opengraph-image.tsx b/app/lookup/[domain]/(dns)/opengraph-image.tsx
index 9fa8fca..14cc7b8 100644
--- a/app/lookup/[domain]/(dns)/opengraph-image.tsx
+++ b/app/lookup/[domain]/(dns)/opengraph-image.tsx
@@ -1,7 +1,9 @@
+import { readFile } from 'node:fs/promises';
+import { join } from 'node:path';
+
import Image from 'next/image';
import { ImageResponse } from 'next/og';
-export const runtime = 'edge';
export const contentType = 'image/png';
const fetchArrayBuffer = async (url: string | URL) =>
@@ -23,7 +25,7 @@ export const handler = async ({ params: paramsPromise }: OGImageProps) => {
fetchArrayBuffer(
'https://fonts.bunny.net/inter/files/inter-latin-700-normal.woff',
),
- fetchArrayBuffer(new URL('@/assets/globe.png', import.meta.url)),
+ readFile(join(process.cwd(), 'assets/globe.png')),
]);
return new ImageResponse(
@@ -159,7 +161,7 @@ export const handler = async ({ params: paramsPromise }: OGImageProps) => {
{/* eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text */}
<img
- src={`data:image/png;base64,${Buffer.from(globeImage).toString('base64')}`}
+ src={`data:image/png;base64,${globeImage.toString('base64')}`}
width={1000}
style={{
position: 'absolute',
diff --git a/app/lookup/[domain]/certs/opengraph-image.tsx b/app/lookup/[domain]/certs/opengraph-image.tsx
index e3cc2dd..ddd3946 100644
--- a/app/lookup/[domain]/certs/opengraph-image.tsx
+++ b/app/lookup/[domain]/certs/opengraph-image.tsx
@@ -1,6 +1,5 @@
import handler from '../(dns)/opengraph-image';
-export const runtime = 'edge';
export const contentType = 'image/png';
export default handler;
diff --git a/app/lookup/[domain]/dnssec/opengraph-image.tsx b/app/lookup/[domain]/dnssec/opengraph-image.tsx
index e3cc2dd..ddd3946 100644
--- a/app/lookup/[domain]/dnssec/opengraph-image.tsx
+++ b/app/lookup/[domain]/dnssec/opengraph-image.tsx
@@ -1,6 +1,5 @@
import handler from '../(dns)/opengraph-image';
-export const runtime = 'edge';
export const contentType = 'image/png';
export default handler;
diff --git a/app/lookup/[domain]/map/opengraph-image.tsx b/app/lookup/[domain]/map/opengraph-image.tsx
index e3cc2dd..ddd3946 100644
--- a/app/lookup/[domain]/map/opengraph-image.tsx
+++ b/app/lookup/[domain]/map/opengraph-image.tsx
@@ -1,6 +1,5 @@
import handler from '../(dns)/opengraph-image';
-export const runtime = 'edge';
export const contentType = 'image/png';
export default handler;
diff --git a/app/lookup/[domain]/subdomains/opengraph-image.tsx b/app/lookup/[domain]/subdomains/opengraph-image.tsx
index e3cc2dd..ddd3946 100644
--- a/app/lookup/[domain]/subdomains/opengraph-image.tsx
+++ b/app/lookup/[domain]/subdomains/opengraph-image.tsx
@@ -1,6 +1,5 @@
import handler from '../(dns)/opengraph-image';
-export const runtime = 'edge';
export const contentType = 'image/png';
export default handler;
diff --git a/app/lookup/[domain]/whois/opengraph-image.tsx b/app/lookup/[domain]/whois/opengraph-image.tsx
index e3cc2dd..ddd3946 100644
--- a/app/lookup/[domain]/whois/opengraph-image.tsx
+++ b/app/lookup/[domain]/whois/opengraph-image.tsx
@@ -1,6 +1,5 @@
import handler from '../(dns)/opengraph-image';
-export const runtime = 'edge';
export const contentType = 'image/png';
export default handler;