Skip to content

Conversation

@ascorbic
Copy link
Contributor

Changes

Adds support for Cloudflare image binding service, from #14027. This is the only service that works with the environment API at the moment. Eventually we'll need to work out what to do with the other services in dev.

Stacked on #14357 so it can use the content layer in testing

Testing

Docs

@changeset-bot
Copy link

changeset-bot bot commented Sep 15, 2025

⚠️ No Changeset found

Latest commit: d4ff53d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Sep 15, 2025
@ascorbic ascorbic self-assigned this Sep 15, 2025
Base automatically changed from env-api-content-layer to feat/environment-api September 15, 2025 13:34
// @ts-expect-error The Header types between libdom and @cloudflare/workers-types are causing issues
export const GET: APIRoute = async (ctx) => {
// @ts-expect-error The runtime locals types are not populated here
return transform(ctx.request.url, ctx.locals.runtime.env.IMAGES, ctx.locals.runtime.env.ASSETS);
Copy link
Member

Choose a reason for hiding this comment

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

I think we should have a similar mechanism for the assets binding, IIUC?

Suggested change
return transform(ctx.request.url, ctx.locals.runtime.env.IMAGES, ctx.locals.runtime.env.ASSETS);
return transform(ctx.request.url, ctx.locals.runtime.env[__ASTRO_IMAGES_BINDING_NAME], ctx.locals.runtime.env.ASSETS);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is all from #14027. This PR is only adding this commit: 45d4efa

Comment on lines +13 to +14
export async function transform(rawUrl: string, images: ImagesBinding, assets: Fetcher) {
const url = new URL(rawUrl);
Copy link
Member

Choose a reason for hiding this comment

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

I think we already pass the url from the endpoint

Suggested change
export async function transform(rawUrl: string, images: ImagesBinding, assets: Fetcher) {
const url = new URL(rawUrl);
export async function transform(url: URL, images: ImagesBinding, assets: Fetcher) {

@ascorbic ascorbic merged commit d5979c2 into feat/environment-api Sep 15, 2025
6 of 19 checks passed
@ascorbic ascorbic deleted the cf-vite-images branch September 15, 2025 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants