From 53118b2b584ad013c2cfa2141feb4ef77cf473f7 Mon Sep 17 00:00:00 2001 From: David Susskind Date: Mon, 20 Jul 2026 15:35:03 +0300 Subject: [PATCH 1/2] fix(dev): scaffold apps with the injected local dev server URL `base44 dev` injects VITE_BASE44_APP_BASE_URL so the app's SDK targets the local dev backend, but the scaffolded base44Client only passed { appId }, so the browser hit the remote backend instead of localhost. Pass serverUrl from the injected env var; it is unset in prod builds, so the SDK falls back to its default server. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../templates/backend-and-client/src/api/base44Client.js.ejs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/cli/templates/backend-and-client/src/api/base44Client.js.ejs b/packages/cli/templates/backend-and-client/src/api/base44Client.js.ejs index c4c0d5967..4eed3f28a 100644 --- a/packages/cli/templates/backend-and-client/src/api/base44Client.js.ejs +++ b/packages/cli/templates/backend-and-client/src/api/base44Client.js.ejs @@ -2,4 +2,8 @@ import { createClient } from '@base44/sdk'; export const base44 = createClient({ appId: '<%= projectId %>', + // `base44 dev` injects VITE_BASE44_APP_BASE_URL (http://localhost:) so the + // SDK targets the local dev backend; unset in prod builds, so it falls back to + // the SDK's default server. + serverUrl: import.meta.env.VITE_BASE44_APP_BASE_URL || undefined, }); From fb3842ad3f98ca48ceffcecd99a24761babdf8ce Mon Sep 17 00:00:00 2001 From: David Susskind Date: Mon, 27 Jul 2026 12:01:15 +0300 Subject: [PATCH 2/2] test(create): assert scaffolded client reads the injected dev server URL Also add a changelog entry for the template fix. Co-Authored-By: Claude Fable 5 --- CHANGELOG.md | 4 ++++ packages/cli/tests/cli/create.spec.ts | 28 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc7e9bdcf..fce1c897e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - App visibility: `base44 visibility ` sets it on the server directly (accepts `--app-id` to target any app). Also configurable via `"visibility"` in `config.jsonc`, which `base44 deploy` applies. New projects scaffold `"visibility": "public"`. +### Fixed + +- Newly scaffolded apps talk to the local dev backend under `base44 dev`: the generated client reads the `VITE_BASE44_APP_BASE_URL` env var the dev server injects, falling back to the production server when unset (e.g. plain `npm run dev`). + ## [0.0.51] - 2026-04-28 ### Added diff --git a/packages/cli/tests/cli/create.spec.ts b/packages/cli/tests/cli/create.spec.ts index 0da624d8b..bb243f28f 100644 --- a/packages/cli/tests/cli/create.spec.ts +++ b/packages/cli/tests/cli/create.spec.ts @@ -76,6 +76,34 @@ describe("create command", () => { expect(config).toContain('"visibility": "public"'); }); + it("scaffolds a client that targets the dev server URL injected by base44 dev", async () => { + await t.givenLoggedIn({ email: "test@example.com", name: "Test User" }); + t.api.mockCreateApp({ id: "dev-url-app-id", name: "Dev Url App" }); + + const projectPath = join(t.getTempDir(), "dev-url-app"); + + const result = await t.run( + "create", + "Dev Url App", + "--path", + projectPath, + "--template", + "backend-and-client", + "--no-skills", + ); + + t.expectResult(result).toSucceed(); + + const client = await readFile( + join(projectPath, "src", "api", "base44Client.js"), + "utf-8", + ); + expect(client).toContain("dev-url-app-id"); + expect(client).toContain( + "serverUrl: import.meta.env.VITE_BASE44_APP_BASE_URL || undefined", + ); + }); + it("infers path from name when --path is not provided", async () => { await t.givenLoggedIn({ email: "test@example.com", name: "Test User" }); t.api.mockCreateApp({ id: "inferred-path-id", name: "My App" });