Skip to content

Commit 097e186

Browse files
committed
handle /_next/image
1 parent 3a010a4 commit 097e186

File tree

1 file changed

+6
-5
lines changed
  • builder/src/build/build-worker/templates

1 file changed

+6
-5
lines changed

builder/src/build/build-worker/templates/worker.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ export default {
3636
const url = new URL(request.url);
3737

3838
if (url.pathname === "/_next/image") {
39-
// TODO: not implemented
40-
return fetch(
39+
let imageUrl =
4140
url.searchParams.get("url") ??
42-
"https://developers.cloudflare.com/_astro/logo.BU9hiExz.svg",
43-
{ cf: { cacheEverything: true } } as any
44-
);
41+
"https://developers.cloudflare.com/_astro/logo.BU9hiExz.svg";
42+
if (imageUrl.startsWith("/")) {
43+
imageUrl = new URL(imageUrl, request.url).href;
44+
}
45+
return fetch(imageUrl, { cf: { cacheEverything: true } } as any);
4546
}
4647

4748
const resBody = new TransformStream();

0 commit comments

Comments
 (0)