mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 07:33:07 +08:00
fix(og-images): wrap Buffer in Uint8Array for Response body (#568)
Astro uses Web API typings; Response doesn’t accept Node Buffer. Convert the generated OG image Buffer to Uint8Array before constructing Response to satisfy BodyInit and fix the build/type error. Closes #560
This commit is contained in:
+4
-2
@@ -1,7 +1,9 @@
|
||||
import type { APIRoute } from "astro";
|
||||
import { generateOgImageForSite } from "@/utils/generateOgImages";
|
||||
|
||||
export const GET: APIRoute = async () =>
|
||||
new Response(await generateOgImageForSite(), {
|
||||
export const GET: APIRoute = async () => {
|
||||
const buffer = await generateOgImageForSite();
|
||||
return new Response(new Uint8Array(buffer), {
|
||||
headers: { "Content-Type": "image/png" },
|
||||
});
|
||||
};
|
||||
|
||||
@@ -27,10 +27,8 @@ export const GET: APIRoute = async ({ props }) => {
|
||||
});
|
||||
}
|
||||
|
||||
return new Response(
|
||||
await generateOgImageForPost(props as CollectionEntry<"blog">),
|
||||
{
|
||||
headers: { "Content-Type": "image/png" },
|
||||
}
|
||||
);
|
||||
const buffer = await generateOgImageForPost(props as CollectionEntry<"blog">);
|
||||
return new Response(new Uint8Array(buffer), {
|
||||
headers: { "Content-Type": "image/png" },
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user