feat: support standalone Docker runtime and internal CMS API

This commit is contained in:
2026-11-03 19:21:59 +08:00
parent 43edc632a5
commit d5c0aa7562
6 changed files with 99 additions and 4 deletions
+15
View File
@@ -137,6 +137,21 @@ test("page fetches share the publish cache tag without changing snippet tags", a
assert.equal(calls[1].next.tags.join(","), "site-settings");
});
test("API client separates container internal and browser addresses", async () => {
const env = { NEXT_PUBLIC_API_URL: "http://localhost:18000", API_INTERNAL_URL: "http://backend:8000" };
for (const browser of [false, true]) {
let requestedURL;
const globals = {
process: { env },
fetch: async (url) => { requestedURL = url; return { ok: true, json: async () => ({}) }; },
...(browser ? { window: {} } : {}),
};
const { fetchAPI } = loadModule("services/api-client.ts", {}, globals);
await fetchAPI("/api/v2/pages/");
assert.equal(requestedURL, `${browser ? env.NEXT_PUBLIC_API_URL : env.API_INTERNAL_URL}/api/v2/pages/`);
}
});
test("authenticated webhook expires shared cache immediately and rejects unauthorized requests", async () => {
const calls = [];
const { POST } = loadModule("app/api/revalidate/route.ts", {