summaryrefslogtreecommitdiff
path: root/packages/integrations/cloudflare/src/entrypoints/image-endpoint.ts
blob: dbc1e1f5ae5e40ba45a80a91db8f027c083567fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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));
};