fix(site): route plugin detail pages through worker shell

This commit is contained in:
t8y2
2026-09-23 16:47:26 +08:00
parent 37a5413641
commit b325c35885
2 changed files with 14 additions and 0 deletions
+12
View File
@@ -1,7 +1,19 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { test } from "vitest";
import { issueRedirectPath, pluginDetailShellRequest, sanitizeReturnTo, signPayload, staticAssetCacheControl, verifySignedPayload } from "../worker";
test("plugin detail shell routes are routed to the worker before static 404 handling", () => {
const wrangler = JSON.parse(readFileSync(new URL("../wrangler.json", import.meta.url), "utf8"));
const runWorkerFirst: string[] = wrangler.assets.run_worker_first;
for (const prefix of ["/cn/plugins", "/en/plugins"]) {
assert.ok(
runWorkerFirst.includes(`${prefix}/*`),
`${prefix}/* missing from run_worker_first; the asset layer would serve the static 404 before the worker shell fallback runs`,
);
}
});
test("signed OAuth payloads round-trip and reject tampering", async () => {
const signed = await signPayload({ login: "dbx-user" }, "test-secret");
assert.deepEqual(await verifySignedPayload<{ login: string }>(signed, "test-secret"), { login: "dbx-user" });
+2
View File
@@ -8,6 +8,8 @@
"not_found_handling": "404-page",
"run_worker_first": [
"/api/*",
"/cn/plugins/*",
"/en/plugins/*",
"/tr",
"/tr/*",
"/issue",