feat: support standalone Docker runtime and internal CMS API
This commit is contained in:
@@ -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", {
|
||||
|
||||
Reference in New Issue
Block a user