-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Add support for Cloudflare images binding in environment API #14358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
| // @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); |
There was a problem hiding this comment.
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?
| 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export async function transform(rawUrl: string, images: ImagesBinding, assets: Fetcher) { | ||
| const url = new URL(rawUrl); |
There was a problem hiding this comment.
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
| 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) { |
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