feat(create): scaffold backend-and-client with the editor-app client convention - #578
Open
davidsu wants to merge 1 commit into
Open
feat(create): scaffold backend-and-client with the editor-app client convention#578davidsu wants to merge 1 commit into
davidsu wants to merge 1 commit into
Conversation
…convention Converge the scaffold's runtime wiring with editor-generated apps so the two species stay portable: @base44/vite-plugin in vite.config.js, the verbatim src/lib/app-params.js boilerplate, and a client that talks same-origin /api (serverUrl: '') instead of a source-baked app id. Under `base44 dev` the plugin proxies /api to the injected local backend URL, so scaffolded apps now hit local entities and functions. The app id resolves at dev/build time from VITE_BASE44_APP_ID / base44/.app.jsonc (plugin fallback) rather than being rendered into base44Client.js. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.1.5-pr.578.bad1ac7Prefer 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.578.bad1ac7"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.1.5-pr.578.bad1ac7"
}
}
Preview published to npm registry — try new features instantly! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Description
The
backend-and-clientscaffold now follows the same client convention that editor-created apps use, so a CLI-created app and an editor-created app share one frontend wiring story. Instead of baking the app id intosrc/api/base44Client.jsat scaffold time, the template resolves app params (app id, access token, functions version, app base url) at runtime and talks to the backend over same-origin/apivia@base44/vite-plugin. Underbase44 devthe plugin proxies/apito the local dev backend, so scaffolded apps get local entities and functions out of the box.Related Issue
None
Type of Change
Changes Made
src/api/base44Client.js- replaced the EJS-templated client (base44Client.js.ejs, which inlinedappId: <%= projectId %>) with a static file that builds the client fromappParams:serverUrl: ""(same-origin/api),requiresAuth: false, plusappId/token/functionsVersion/appBaseUrl. The app id is no longer written into source - it resolves from env orbase44/.app.jsonc.src/lib/app-params.js(new) - resolves each app param from URL query string ->localStorage-> Vite env default (VITE_BASE44_APP_ID,VITE_BASE44_FUNCTIONS_VERSION,VITE_BASE44_APP_BASE_URL), stripsaccess_tokenfrom the URL after reading it, caches values underbase44_*keys, and clears the stored token whenclear_access_token=true. Guarded for non-browser (typeof window === "undefined") evaluation.vite.config.js- added@base44/vite-pluginto the plugin list and dropped the hand-rolled@->./srcalias and thepathimport; the plugin supplies the alias and the/apidev proxy (jsconfig.jsonalready declares@/*for editors).package.json- bumped@base44/sdk^0.8.3->^0.8.40and added@base44/vite-plugin^1.0.30.packages/cli/tests/cli/create.spec.ts- new integration test asserting a scaffoldedbackend-and-clientproject hasserverUrl: ""and the@/lib/app-paramsimport, does not contain the app id inbase44Client.js, shipssrc/lib/app-params.jsreferencing theVITE_BASE44_*vars, wires@base44/vite-plugininvite.config.js, and still writes the app id intobase44/.app.jsonc.CHANGELOG.md- added a### Changedentry describing the new template convention.Testing
npm test)Checklist
docs/(AGENTS.md) if I made architectural changesAdditional Notes
base44 devalready injectsVITE_BASE44_APP_IDandVITE_BASE44_APP_BASE_URLinto the frontendserveCommand(packages/cli/src/cli/dev/dev-server/main.ts), which is what the newapp-params.jsdefaults read - the two halves line up.base44 ejectalso writesVITE_BASE44_APP_ID.requiresAuth: falsekeeps the scaffold anonymously browsable; apps that need a signed-in user should flip it totrue.src/lib/app-params.jsis intentionally kept close to the editor-app version (tabs,//-style comment in the client) so the two conventions do not drift; it is not reformatted to the CLI repo Biome style.@base44/vite-plugindependency is a template dependency (installed in scaffolded user projects), not a CLI dependency, so the zero-dependency distribution rule is unaffected.docs/updates: this changes template contents only, not CLI architecture.bun run buildand the test suite were not executed in this environment (command approval was declined), so the two unchecked Testing boxes reflect what I could confirm from the diff rather than a known failure.🤖 Generated by Claude | 2026-07-27 11:20 UTC | e827f85