R65 A1-A6:Session 稳定性与 409 资源错误修复
ci-e2e / e2e (push) Waiting to run
ci-minimal / check-minimal (push) Waiting to run

这个提交包含在:
2026-04-16 20:23:54 +08:00
父节点 bc6e4955b3
当前提交 8353efcbd7
共修改 7 个文件,包含 425 行新增和 11 行删除
+24
查看文件
@@ -78,6 +78,27 @@ const { initMetrics } = require("./observability");
const { AppError } = require("./utils/AppError");
const { buildDataEnvelopeSchema, buildErrorEnvelopeSchema } = require("./utils/openapi");
const NO_CACHE_STATIC_FILES = new Set([
"index.html",
"sw.js",
"manifest.webmanifest",
"registerSW.js",
]);
function setStaticCacheHeaders(res, filePath) {
const normalizedPath = String(filePath).replace(/\\/g, "/");
const fileName = normalizedPath.split("/").pop() ?? "";
if (NO_CACHE_STATIC_FILES.has(fileName)) {
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
return;
}
if (normalizedPath.includes("/assets/") || /\/workbox-[^/]+\.js$/i.test(normalizedPath)) {
res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
}
}
async function buildApp() {
const config = getConfig();
@@ -151,7 +172,9 @@ async function buildApp() {
if (config.serveClientDist) {
await app.register(staticPlugin, {
cacheControl: false,
root: config.clientDistDir,
setHeaders: setStaticCacheHeaders,
});
app.log.info({ dir: config.clientDistDir }, "Client dist static serving enabled");
}
@@ -172,6 +195,7 @@ async function buildApp() {
request.headers.accept.includes("text/html") &&
typeof reply.sendFile === "function"
) {
reply.header("Cache-Control", "no-cache, no-store, must-revalidate");
return reply.type("text/html").sendFile("index.html");
}