Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/modules/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions tests/unit/functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
});
Expand Down Expand Up @@ -498,15 +498,15 @@ 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)
);

// Test without leading slash
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)
);
});
Expand Down
Loading