From a49092cf16b6e1a9014f520b2ee067c7c1765c22 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 25 Sep 2026 22:04:51 +0900 Subject: [PATCH] fix(release): bust cached application assets --- scripts/build.mjs | 4 +++- worker/index.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index 6eab86b..e77bfaa 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -7,7 +7,9 @@ const meta = new URL("../dist/.openai/", import.meta.url); await rm(dist, { recursive: true, force: true }); await Promise.all([mkdir(server, { recursive: true }), mkdir(meta, { recursive: true })]); -const [indexHtml, addonsJs] = await Promise.all([text("index.html"), text("addons.js")]); +const [rawIndexHtml, addonsJs] = await Promise.all([text("index.html"), text("addons.js")]); +const release = "1.0.0"; +const indexHtml = rawIndexHtml.replace('src="addons.js"', `src="addons.js?v=${release}"`); await writeFile(new URL("assets.js", server), `export const indexHtml=${JSON.stringify(indexHtml)};\nexport const addonsJs=${JSON.stringify(addonsJs)};\n`); await copyFile(new URL("../worker/index.js", import.meta.url), new URL("index.js", server)); await copyFile(new URL("../.openai/hosting.json", import.meta.url), new URL("hosting.json", meta)); diff --git a/worker/index.js b/worker/index.js index 9215749..cade2ba 100644 --- a/worker/index.js +++ b/worker/index.js @@ -33,7 +33,7 @@ export default { } catch (error) { return Response.json({ error: "Bing wallpaper is temporarily unavailable", detail: String(error) }, { status: 502 }); } - if (url.pathname === "/addons.js") return new Response(addonsJs, { headers: headers("application/javascript; charset=utf-8") }); + if (url.pathname === "/addons.js") return new Response(addonsJs, { headers: headers("application/javascript; charset=utf-8", "no-cache") }); if (url.pathname === "/" || url.pathname === "/index.html") return new Response(indexHtml, { headers: headers("text/html; charset=utf-8", "no-cache") }); return new Response("Not found", { status: 404 }); },