How to Create a Backend API on Wix CLI

I am creating a Backend API using Wix CLI. I have run ‘npm run generate’ to create HTTP functions.

On calling the GET method on the dashboard page, I am getting an error.

Here’s the implementation on the dashboard page:

import { httpClient } from ‘@wix/essentials’;

const callMyBackend = async () => {

try {

const apiUrl = import.meta.env.BASE_API_URL;

if (!apiUrl) return;

const res = await httpClient.fetchWithAuth(\`${apiUrl}/additional-fees\`, {

  method: 'GET'

});

if (res.ok) {

  const data = await res.json();

  console.log(data);

}

} catch (err) {

console.error("Fetch failed:", err);

}

};

Here’s the error:

page.tsx:237 GET http://localhost:5173/functions/additional-fees 500 (Internal Server Error)

Are you using the legacy CLI or the new CLI?

I believe that the method has been updated for the New CLI where it now uses the Astro framework. Check these docs - Wix CLI Docs

I have tried the new CLI but still getting the same error. I am also trying to create a new app using the new CLI with the following command:
npm create @wix/new@latest app

but I am getting the following error.