feat(create): scaffold backend-and-client on the vite-plugin client convention - #580
Conversation
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.1.8-pr.580.14c640aPrefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.1.8-pr.580.14c640a"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.1.8-pr.580.14c640a"
}
}
Preview published to npm registry — try new features instantly! |
|
Cryptoease |
…44 build, deploy --build The full #580 feature set, rebuilt on top of the decoupled serveCommand runner (#582). dev --remote is now just: resolve the configured serveCommand (or fail), resolve the app's published URL (or fail), run the same runner local dev uses — no backend, no parallel implementation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2253db8 to
bee958d
Compare
…44 build, deploy --build The full #580 feature set, rebuilt on top of the decoupled serveCommand runner (#582). dev --remote is now just: resolve the configured serveCommand (or fail), resolve the app's published URL (or fail), run the same runner local dev uses — no backend, no parallel implementation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
bee958d to
474fd00
Compare
…44 build, deploy --build The full #580 feature set, rebuilt on top of the decoupled serveCommand runner (#582). dev --remote is now just: resolve the configured serveCommand (or fail), resolve the app's published URL (or fail), run the same runner local dev uses — no backend, no parallel implementation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0b64316 to
2bd3942
Compare
2bd3942 to
dd0802f
Compare
…44 build, deploy --build The full #580 feature set, rebuilt on top of the decoupled serveCommand runner (#582). dev --remote is now just: resolve the configured serveCommand (or fail), resolve the app's published URL (or fail), run the same runner local dev uses — no backend, no parallel implementation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
dd0802f to
e8ac198
Compare
…onvention The template adopts the same client wiring editor-created apps use: @base44/vite-plugin (supplies the @ alias and the /api dev proxy) + src/lib/app-params.js (the refactored env-only version from apper#18730, byte-identical) + a static base44Client.js on same-origin /api (serverUrl: ''). The app id leaves scaffolded source: it is injected at serve/build time via VITE_BASE44_APP_ID — by base44 dev, dev --remote, build, and deploy --build — instead of being baked in by create. The post-scaffold build in create/scaffold injects it too, and the missing-build-output hint now points at base44 build. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
c584d20 to
35ecce5
Compare
| } | ||
| return { | ||
| appId: import.meta.env.VITE_BASE44_APP_ID, | ||
| token: getAccessToken(), |
There was a problem hiding this comment.
dont need this here, the SDK handles it internally, and I think we'd rather keep it there
There was a problem hiding this comment.
same in app params PR in apper
There was a problem hiding this comment.
right, though looks like something else breaks:
https://github.com/base44-dev/apper/blob/2479b59dd6a85bdadd7a2d6a922b7149563f9c2f/templates/apps_template/src/lib/AuthContext.jsx#L33-L42 -> seems to bypass the sdk and break if app-params doesn't return the token, am I missing something?
https://github.com/base44-dev/apper/blob/2479b59dd6a85bdadd7a2d6a922b7149563f9c2f/backend/app/user_apps/auth_templates/files/OAuthConsent.jsx#L38 -> same, raw fetch (also L89)
we hit this on the apper side - dropped the storage fallback and in-iframe reloads rendered signed out while sdk calls kept working.
There was a problem hiding this comment.
I see, yeah we need to tackle those, they are very problematic.
for the first one - it does
import { createAxiosClient } from '@base44/sdk/dist/utils/axios-client';
which is very bad by itself as that path is not formal api and we will break it unknowingly
this whole call should just be in the SDK itself in the frist place, so the template code doesnt try to read the access token and isnt aware of api paths. so let's introduce a new method for it in the SDK.
(more over I dont know why we still have a call to public_settings in the template since we moved to protecting private apps on the server. @roymiloh why do we still call it?)
for the second one - I think we can get the token from an initialized client nope? dont we have a method for that?
There was a problem hiding this comment.
@netanelgilad went on vacations. @guyofeck and I decided to merge this as is and leave further improvements for way down the line
| return { | ||
| appId: import.meta.env.VITE_BASE44_APP_ID, | ||
| token: getAccessToken(), | ||
| functionsVersion: import.meta.env.VITE_BASE44_FUNCTIONS_VERSION, |
There was a problem hiding this comment.
I think this one should be read from query parameter and not env var (is there a code path where we inject this as env var? I think we only ever place it as a query parameter, take a look in apper code)
There was a problem hiding this comment.
I think it's the other way around
https://github.com/base44-dev/apper/blob/2479b59dd6a85bdadd7a2d6a922b7149563f9c2f/backend/app/user_apps/sandbox/providers/sandbox_provider.py#L1076-L1078 sets the env var. I can't find anyplace setting functions_version queryParam, I don't think there is one.
There was a problem hiding this comment.
@netanelgilad went on vacations. @guyofeck and I decided to merge this as is and leave further improvements for way down the line
Mirrors apper fbab06de98f (PR #18730) per Netanel's #580 review: the SDK already defaults requiresAuth to false, so the template stops passing it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
guyofeck
left a comment
There was a problem hiding this comment.
Create a github issue for the app params left over and merge it 🔥
Note
Description
The
backend-and-clientscaffold now uses the same client wiring that editor-created Base44 apps use, so both app species share one convention.vite.config.jsloads@base44/vite-plugin(which supplies the@alias and the/apidev proxy), the SDK client talks to a same-origin/api(serverUrl: ''), and the app id is no longer baked into scaffolded source — it arrives at run/build time throughVITE_BASE44_APP_ID. Scaffolded apps therefore get local entities and functions underbase44 dev, and work unchanged against the production backend underbase44 dev --remote.Related Issue
None. Related PRs: #586, #587, #588 — the other three slices of the original unified local-dev rescope, already merged; this PR is the remaining template-convergence slice. The
src/lib/app-params.jscopy tracks base44-dev/apper#18730.Type of Change
Changes Made
templates/backend-and-client/vite.config.js— replaced the manualresolve.aliasblock with thebase44()Vite plugin (base44()+react()); the plugin supplies the@alias and proxies/apito the local dev backend.templates/backend-and-client/src/lib/app-params.js(new) — readsappId,functionsVersion, andappBaseUrlfromimport.meta.env, delegates the token to the SDK'sgetAccessToken(), and honors?clear_access_token=trueby clearing the stored token. Verbatim copy of the upstream apper file.templates/backend-and-client/src/api/base44Client.js(new, static) —createClientfed fromappParams, on same-origin/api(serverUrl: '',requiresAuth: false).templates/backend-and-client/src/api/base44Client.js.ejs(deleted) — the app id is no longer templated into scaffolded source at create time.templates/backend-and-client/package.json— bumped@base44/sdkto^0.8.40(for thegetAccessTokenexport) and added@base44/vite-plugin^1.0.30.cli/commands/project/scaffold-shared.ts— the post-scaffold build now runs withVITE_BASE44_APP_IDset to the new project id, so the first build carries the app id even though it is no longer in source.core/site/deploy.ts— both missing/empty output-directory hints now point atbase44 build(which injects the app id) instead of a barenpm run build.CHANGELOG.md— added aChangedentry describing the new template convention.Testing
npm test)Added
create.spec.ts→ "scaffolds backend-and-client with the editor-app client convention", asserting the scaffolded client usesserverUrl: ''and@/lib/app-paramsand does not hardcode the app id, thatapp-params.jsreadsVITE_BASE44_APP_ID/VITE_BASE44_APP_BASE_URL, thatvite.config.jsreferences@base44/vite-plugin, and that the app id still lands inbase44/.app.jsonc.build,lint,typecheck, andknipare green on CI; the four test-matrix jobs (ubuntu/windows × npm/binary) were still pending when this description was generated, so the "all tests pass" box is left unchecked rather than claimed.Checklist
docs/(AGENTS.md) if I made architectural changesAdditional Notes
src/lib/app-params.jsis a verbatim copy of the upstream apper file and must not diverge from it; if that upstream PR changes in review, re-copy the file here.@base44/vite-pluginfor the@alias and the/apiproxy. Existing projects are untouched — only newly scaffolded apps lose the hardcoded-appIdclient.npm run buildin a scaffolded project produces a bundle without an app id;base44 build(orbase44 deploy --build) is the supported path, which is why the deploy hints were reworded.docs/update: this changes template contents and one env var passed to a build, not CLI architecture — theCHANGELOG.mdentry covers the user-visible behavior.🤖 Generated by Claude | 2026-08-04 11:52 UTC | 14c640a