diff options
Diffstat (limited to 'packages/integrations/cloudflare/src')
-rw-r--r-- | packages/integrations/cloudflare/src/entrypoints/image-endpoint.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/packages/integrations/cloudflare/src/entrypoints/image-endpoint.ts b/packages/integrations/cloudflare/src/entrypoints/image-endpoint.ts index ab51f42f2..dbc1e1f5a 100644 --- a/packages/integrations/cloudflare/src/entrypoints/image-endpoint.ts +++ b/packages/integrations/cloudflare/src/entrypoints/image-endpoint.ts @@ -1,2 +1,15 @@ -// NOTE: this file is empty on purpose -// it allows use to offer `imageService: 'compile'` +import type { APIRoute } from 'astro'; + +export const prerender = false; + +export const GET: APIRoute = (ctx) => { + const href = ctx.url.searchParams.get('href'); + if (!href) { + return new Response("Missing 'href' query parameter", { + status: 400, + statusText: "Missing 'href' query parameter", + }); + } + + return fetch(new URL(href, ctx.url.origin)); +}; |