← Files Product DesignARCHIVED FILE
templates/prototype/worker/index.js
483 Bytes · Oct 4, 2026 · 12:03 UTC
export default {
async fetch(request, env) {
const response = await env.ASSETS.fetch(request);
const acceptsHtml = request.headers.get("accept")?.includes("text/html");
if (response.status !== 404 || !acceptsHtml || !["GET", "HEAD"].includes(request.method)) {
return response;
}
const indexUrl = new URL(request.url);
indexUrl.pathname = "/index.html";
indexUrl.search = "";
return env.ASSETS.fetch(new Request(indexUrl, request));
},
};
SHA-256: 2dd0615a445143933d88d4271f54f5d63ee951421fcd08c5a7617bb09c564389