Skip to content

fix: generateOgImageForSite error#568

Merged
satnaing merged 3 commits into
satnaing:mainfrom
iamStephenFang:fix/og_image_build_issue
Aug 21, 2025
Merged

fix: generateOgImageForSite error#568
satnaing merged 3 commits into
satnaing:mainfrom
iamStephenFang:fix/og_image_build_issue

Conversation

@iamStephenFang

Copy link
Copy Markdown
Contributor

Description

generateOgImageForSite() / generateOgImageForPost() return a Buffer, but in TypeScript’s type definitions, new Response() does not accept Node.js Buffer—it only accepts Web platform BodyInit types (such as Blob, ArrayBuffer, Uint8Array, etc.).

Astro uses Web API type definitions (dom lib) during build time, so Node.js Buffer types won’t match. Just simply convert the Buffer to a Uint8Array or ArrayBuffer to pass type checking.

Types of changes

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Documentation Update (if none of the other choices apply)
  • Others (any other types not listed above)

Checklist

  • I have read the Contributing Guide
  • I have added the necessary documentation (if appropriate)
  • Breaking Change (fix or feature that would cause existing functionality to not work as expected)

Further comments

Related Issue

It will fixed this issue

Closes: #560

alec-c4 added a commit to alec-c4/alec-c4.com that referenced this pull request Aug 12, 2025
satnaing
satnaing previously approved these changes Aug 21, 2025

@satnaing satnaing left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@satnaing

Copy link
Copy Markdown
Owner

BTW,
The CI flow failed.
Can you update the code formatting, please @iamStephenFang ?
pnpm format

@iamStephenFang

Copy link
Copy Markdown
Contributor Author

BTW, The CI flow failed. Can you update the code formatting, please @iamStephenFang ? pnpm format

Sure, I've pushed the new commit, sorry about code format issue

@satnaing
satnaing merged commit aad5ac6 into satnaing:main Aug 21, 2025
1 check passed
jxgla pushed a commit to jxgla/astro-paper that referenced this pull request Mar 10, 2026
…#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 satnaing#560
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: After building, the/og.png fetch failed

2 participants