diff options
author | 2024-08-03 08:22:57 +0200 | |
---|---|---|
committer | 2024-08-03 08:22:57 +0200 | |
commit | 543beda4f21e1e212626f515af0d3553c7f2a9f3 (patch) | |
tree | 8ccd0e137feed7ca28598a46bf803a3fa07d3530 /packages/integrations/cloudflare/src | |
parent | a8a6a55884ea46e1765624f681cef70d17b6df09 (diff) | |
download | astro-543beda4f21e1e212626f515af0d3553c7f2a9f3.tar.gz astro-543beda4f21e1e212626f515af0d3553c7f2a9f3.tar.zst astro-543beda4f21e1e212626f515af0d3553c7f2a9f3.zip |
fix(cloudflare): add proxy /_image endpoint (#335)
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
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)); +}; |