Skip to content

fix(dev): scaffold apps with the injected local dev server URL#571

Open
davidsu wants to merge 1 commit into
mainfrom
fix/dev-template-server-url
Open

fix(dev): scaffold apps with the injected local dev server URL#571
davidsu wants to merge 1 commit into
mainfrom
fix/dev-template-server-url

Conversation

@davidsu

@davidsu davidsu commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Note

Description

Newly scaffolded backend-and-client apps ignored the local dev backend because the generated Base44 client had no way to point at it. This PR wires the client template to read the VITE_BASE44_APP_BASE_URL env var that base44 dev injects (pointing at http://localhost:<port>), so scaffolded apps talk to the local dev server during development while still falling back to the SDK default in production builds.

Related Issue

None

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

  • Set serverUrl: import.meta.env.VITE_BASE44_APP_BASE_URL || undefined on the generated createClient() call in the backend-and-client template (base44Client.js.ejs).
  • Added an explanatory comment clarifying that the URL is injected by base44 dev and is unset in production builds, so the SDK falls back to its default server.

Testing

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

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

The env var name matches what the dev server sets in packages/cli/src/cli/dev/dev-server/main.ts (VITE_BASE44_APP_BASE_URL). This is a template-only change; existing generated projects are unaffected until re-scaffolded.


🤖 Generated by Claude | 2026-07-20 12:36 UTC | 8e6eea5

`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>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.1.5-pr.571.4d6a59e

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.5-pr.571.4d6a59e"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.1.5-pr.571.4d6a59e"
  }
}

Preview published to npm registry — try new features instantly!

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.

1 participant