Skip to content

fix(astro): set the image endpoint entrypoint so /_image works - #679

Merged
leoortizz merged 2 commits into
mainfrom
fix/astro-image-endpoint
Aug 12, 2026
Merged

fix(astro): set the image endpoint entrypoint so /_image works#679
leoortizz merged 2 commits into
mainfrom
fix/astro-image-endpoint

Conversation

@leoortizz

Copy link
Copy Markdown
Member

image.endpoint is an object ({ route, entrypoint }), not a string, so
config.image.endpoint ?? "astro/assets/endpoint/node" never fired — the object
is always truthy. The entrypoint was therefore never set, no /_image route was
built, and every optimized image 404'd at runtime while the adapter advertised
sharpImageService: "stable".

Sets entrypoint inside the object, keeping Astro's dev endpoint for astro dev
and using the Node one for builds, and passes route through so a custom route
still works. Mirrors @astrojs/node's own handling.

Verified on App Hosting deployments of Astro 5, 6 and 7, checking the served
image's dimensions, file type and quality.

`image.endpoint` is an object (`{ route, entrypoint }`), not a string, so
`config.image.endpoint ?? "astro/assets/endpoint/node"` never fired — the object
is always truthy. The entrypoint was therefore never set, no /_image route was
built, and every optimized image 404'd at runtime while the adapter advertised
`sharpImageService: "stable"`.

Sets `entrypoint` inside the object, keeping Astro's dev endpoint for `astro dev`
and using the Node one for builds, and passes `route` through so a custom route
still works. Mirrors @astrojs/node's own handling.

Verified on App Hosting deployments of Astro 5, 6 and 7, checking the served
image's dimensions, file type and quality.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces dynamic resolution of the Astro image endpoint entrypoint based on the execution command (e.g., using the dev endpoint for astro dev and the Node endpoint for builds), along with corresponding unit tests. The reviewer identified a potential crash if config.image.endpoint is undefined, and suggested using optional chaining to safely access its properties.

Comment thread packages/@apphosting/experimental/adapter-astro/src/index.ts Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@leoortizz
leoortizz merged commit b2e071f into main Aug 12, 2026
21 checks passed
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.

2 participants