diff --git a/src/modules/functions.ts b/src/modules/functions.ts index 1a72c1d..01624b8 100644 --- a/src/modules/functions.ts +++ b/src/modules/functions.ts @@ -86,7 +86,7 @@ export function createFunctionsModule( // Fetch a backend function endpoint directly. async fetch(path: string, init: FunctionsFetchInit = {}) { const normalizedPath = path.startsWith("/") ? path : `/${path}`; - const primaryPath = `/functions${normalizedPath}`; + const primaryPath = `/apps/${appId}/functions${normalizedPath}`; const headers = toHeaders(init.headers); diff --git a/tests/unit/functions.test.ts b/tests/unit/functions.test.ts index 9a55379..06e87c6 100644 --- a/tests/unit/functions.test.ts +++ b/tests/unit/functions.test.ts @@ -468,7 +468,7 @@ describe("Functions Module", () => { expect(fetchMock).toHaveBeenCalledTimes(1); expect(fetchMock).toHaveBeenCalledWith( - `${serverUrl}/api/functions/my_function`, + `${serverUrl}/api/apps/${appId}/functions/my_function`, expect.any(Object) ); }); @@ -498,7 +498,7 @@ describe("Functions Module", () => { fetchMock.mockResolvedValueOnce(new Response("ok", { status: 200 })); await base44.functions.fetch("/my_function"); expect(fetchMock).toHaveBeenCalledWith( - `${serverUrl}/api/functions/my_function`, + `${serverUrl}/api/apps/${appId}/functions/my_function`, expect.any(Object) ); @@ -506,7 +506,7 @@ describe("Functions Module", () => { fetchMock.mockResolvedValueOnce(new Response("ok", { status: 200 })); await base44.functions.fetch("my_function"); expect(fetchMock).toHaveBeenCalledWith( - `${serverUrl}/api/functions/my_function`, + `${serverUrl}/api/apps/${appId}/functions/my_function`, expect.any(Object) ); });