Skip to content

Commit

Permalink
handle /_next/image
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Sep 13, 2024
1 parent 3a010a4 commit 097e186
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions builder/src/build/build-worker/templates/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ export default {
const url = new URL(request.url);

if (url.pathname === "/_next/image") {
// TODO: not implemented
return fetch(
let imageUrl =
url.searchParams.get("url") ??
"https://developers.cloudflare.com/_astro/logo.BU9hiExz.svg",
{ cf: { cacheEverything: true } } as any
);
"https://developers.cloudflare.com/_astro/logo.BU9hiExz.svg";
if (imageUrl.startsWith("/")) {
imageUrl = new URL(imageUrl, request.url).href;
}
return fetch(imageUrl, { cf: { cacheEverything: true } } as any);
}

const resBody = new TransformStream();
Expand Down

0 comments on commit 097e186

Please sign in to comment.