Skip to content

Commit b35ec47

Browse files
committed
route to 404 via worker
1 parent 73f4168 commit b35ec47

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

worker/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ export default class extends WorkerEntrypoint<Env> {
9898
console.error("Unknown error", error);
9999
}
100100

101-
return this.env.ASSETS.fetch(request);
101+
const response = await this.env.ASSETS.fetch(request);
102+
103+
if (response.status === 404) {
104+
const section = new URL(response.url).pathname.split("/").at(1);
105+
106+
if (!section) return response;
107+
108+
return this.env.ASSETS.fetch(`http://fakehost/${section}/404/`);
109+
}
110+
111+
return response;
102112
}
103113
}

0 commit comments

Comments
 (0)