fix(dev): scaffold apps with the injected local dev server URL - #571
fix(dev): scaffold apps with the injected local dev server URL#571davidsu wants to merge 2 commits into
Conversation
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.1.5-pr.571.7e17867Prefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.1.5-pr.571.7e17867"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.1.5-pr.571.7e17867"
}
}
Preview published to npm registry — try new features instantly! |
`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) <noreply@anthropic.com>
Also add a changelog entry for the template fix. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
8e6eea5 to
fb3842a
Compare
|
Rebased on main and extended: added a create-command test asserting the scaffolded client reads Context from today's investigation: this is the missing half of the env-var contract — |
|
Superseded — closing per today's design decision. The approach changed from a direct env-var read in the template to converging the scaffold onto the editor-app convention: |
Note
Description
Newly scaffolded
backend-and-clientapps hardcoded noserverUrl, so the generated@base44/sdkclient always talked to the production Base44 server — even when running underbase44 dev, which spins up a local backend. This PR makes the scaffolded client read theVITE_BASE44_APP_BASE_URLenv var that the dev server already injects into thesite.serveCommandprocess, falling back to the SDK default when the var is unset (plainnpm run dev, production builds). No CLI code changes are needed; the dev server already exports the variable inpackages/cli/src/cli/dev/dev-server/main.ts.Related Issue
None
Type of Change
Changes Made
packages/cli/templates/backend-and-client/src/api/base44Client.js.ejs: passserverUrl: import.meta.env.VITE_BASE44_APP_BASE_URL || undefinedtocreateClient(), with a comment explaining the dev-vs-prod behavior.packages/cli/tests/cli/create.spec.ts: new integration test asserting thatbase44 create --template backend-and-clientscaffoldssrc/api/base44Client.jscontaining both the app id and theserverUrlenv-var read.CHANGELOG.md: added a### Fixedentry under the unreleased section.Testing
npm test)Checklist
docs/(AGENTS.md) if I made architectural changesAdditional Notes
The fallback is
|| undefinedrather than an empty string so the SDK applies its own default server URL instead of receiving a falsy override. Only thebackend-and-clienttemplate is affected; other templates do not generate an SDK client. The test suite was not executed in this environment (build/test commands were unavailable), so the "tested locally" and "all tests pass" boxes are left unchecked pending CI.🤖 Generated by Claude | 2026-07-27 09:01 UTC | 7e17867