Skip to content

feat(create): scaffold backend-and-client on the vite-plugin client convention - #580

Merged
davidsu merged 2 commits into
mainfrom
feat/dev-remote-vite-plugin-template
Aug 6, 2026
Merged

feat(create): scaffold backend-and-client on the vite-plugin client convention#580
davidsu merged 2 commits into
mainfrom
feat/dev-remote-vite-plugin-template

Conversation

@davidsu

@davidsu davidsu commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Note

Description

The backend-and-client scaffold now uses the same client wiring that editor-created Base44 apps use, so both app species share one convention. vite.config.js loads @base44/vite-plugin (which supplies the @ alias and the /api dev 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 through VITE_BASE44_APP_ID. Scaffolded apps therefore get local entities and functions under base44 dev, and work unchanged against the production backend under base44 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.js copy tracks base44-dev/apper#18730.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • templates/backend-and-client/vite.config.js — replaced the manual resolve.alias block with the base44() Vite plugin (base44() + react()); the plugin supplies the @ alias and proxies /api to the local dev backend.
  • templates/backend-and-client/src/lib/app-params.js (new) — reads appId, functionsVersion, and appBaseUrl from import.meta.env, delegates the token to the SDK's getAccessToken(), and honors ?clear_access_token=true by clearing the stored token. Verbatim copy of the upstream apper file.
  • templates/backend-and-client/src/api/base44Client.js (new, static) — createClient fed from appParams, 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/sdk to ^0.8.40 (for the getAccessToken export) and added @base44/vite-plugin ^1.0.30.
  • cli/commands/project/scaffold-shared.ts — the post-scaffold build now runs with VITE_BASE44_APP_ID set 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 at base44 build (which injects the app id) instead of a bare npm run build.
  • CHANGELOG.md — added a Changed entry describing the new template convention.

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Added create.spec.ts → "scaffolds backend-and-client with the editor-app client convention", asserting the scaffolded client uses serverUrl: '' and @/lib/app-params and does not hardcode the app id, that app-params.js reads VITE_BASE44_APP_ID / VITE_BASE44_APP_BASE_URL, that vite.config.js references @base44/vite-plugin, and that the app id still lands in base44/.app.jsonc. build, lint, typecheck, and knip are 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

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated docs/ (AGENTS.md) if I made architectural changes

Additional Notes

  • src/lib/app-params.js is 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.
  • New scaffolds now depend on @base44/vite-plugin for the @ alias and the /api proxy. Existing projects are untouched — only newly scaffolded apps lose the hardcoded-appId client.
  • Because the app id is injected rather than baked in, a bare npm run build in a scaffolded project produces a bundle without an app id; base44 build (or base44 deploy --build) is the supported path, which is why the deploy hints were reworded.
  • No docs/ update: this changes template contents and one env var passed to a build, not CLI architecture — the CHANGELOG.md entry covers the user-visible behavior.

🤖 Generated by Claude | 2026-08-04 11:52 UTC | 14c640a

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.1.8-pr.580.14c640a

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.1.8-pr.580.14c640a"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.1.8-pr.580.14c640a"
  }
}

Preview published to npm registry — try new features instantly!

@chimamark199713-dev

Copy link
Copy Markdown

Cryptoease

@davidsu davidsu changed the title feat(dev): base44 dev --remote + template scaffolds the vite-plugin convention feat: local-dev rescope — base44 dev --remote, template on vite-plugin, base44 build, deploy --build Jul 30, 2026
davidsu added a commit that referenced this pull request Jul 30, 2026
…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>
@davidsu
davidsu force-pushed the feat/dev-remote-vite-plugin-template branch from 2253db8 to bee958d Compare July 30, 2026 13:01
@davidsu
davidsu changed the base branch from main to refactor/decouple-serve-command July 30, 2026 13:01
Base automatically changed from refactor/decouple-serve-command to main July 30, 2026 13:08
davidsu added a commit that referenced this pull request Jul 30, 2026
…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>
@davidsu
davidsu force-pushed the feat/dev-remote-vite-plugin-template branch from bee958d to 474fd00 Compare July 30, 2026 13:09
davidsu added a commit that referenced this pull request Aug 3, 2026
…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>
@davidsu
davidsu force-pushed the feat/dev-remote-vite-plugin-template branch 2 times, most recently from 0b64316 to 2bd3942 Compare August 3, 2026 11:52
@davidsu
davidsu force-pushed the feat/dev-remote-vite-plugin-template branch from 2bd3942 to dd0802f Compare August 3, 2026 12:23
davidsu added a commit that referenced this pull request Aug 3, 2026
…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>
@davidsu
davidsu force-pushed the feat/dev-remote-vite-plugin-template branch from dd0802f to e8ac198 Compare August 3, 2026 13:20
…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>
@davidsu
davidsu force-pushed the feat/dev-remote-vite-plugin-template branch from c584d20 to 35ecce5 Compare August 4, 2026 11:50
@davidsu davidsu changed the title feat: local-dev rescope — base44 dev --remote, template on vite-plugin, base44 build, deploy --build feat(create): scaffold backend-and-client on the vite-plugin client convention Aug 4, 2026
}
return {
appId: import.meta.env.VITE_BASE44_APP_ID,
token: getAccessToken(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont need this here, the SDK handles it internally, and I think we'd rather keep it there

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same in app params PR in apper

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@netanelgilad went on vacations. @guyofeck and I decided to merge this as is and leave further improvements for way down the line

Comment thread packages/cli/templates/backend-and-client/src/api/base44Client.js Outdated
netanelgilad
netanelgilad previously approved these changes Aug 4, 2026
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>
@davidsu
davidsu enabled auto-merge (squash) August 6, 2026 09:25
@guyofeck
guyofeck self-requested a review August 6, 2026 12:25

@guyofeck guyofeck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a github issue for the app params left over and merge it 🔥

@davidsu
davidsu merged commit 8438727 into main Aug 6, 2026
@davidsu
davidsu deleted the feat/dev-remote-vite-plugin-template branch August 6, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants