fix(admin-api): bypass browser cache locks for live requests

Use no-store on both client requests and admin responses. Personalized live data must not be reused, and one stalled same-URL cache entry must not block later log requests behind the browser cache lock.
This commit is contained in:
翅膀 committed 2026-10-17 18:16:49 +08:00
1 parent 6cdcedde92
commit 82206b066a
3 files changed
+27 -1

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
import { describe, it, expect } from "bun:test";
import handler from "../server/routes/admin/api/[...slug]";
import { makeEvent, responseHeader, responseStatus } from "./helpers";
describe("admin API route", () => {
it("never lets a response be cached", async () => {
const event = makeEvent("/admin/api/nope", { env: { GITHUB_WEBHOOK_SECRET: "s" } as never });
event.context.params = { slug: "nope" };
const res = await handler(event);
expect(responseStatus(event)).toBe(404);
expect(res).toEqual({ error: "Not found" });
expect(responseHeader(event, "cache-control")).toBe("no-store");
});
});