Skip to content

fix(templates): preserve Varlock ENV access and scope deployment URLs - #1238

Merged
AmanVarshney01 merged 3 commits into
mainfrom
fix/template-client-deployment-wiring
Sep 14, 2026
Merged

AmanVarshney01 merged 3 commits into
mainfrom
fix/template-client-deployment-wiring

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

Generated clients imported Varlock as ENV as env, preventing the Vite integration from replacing ENV.KEY accesses and causing the browser to crash when reading the server URL. Preserve the canonical ENV import and accesses across web/native auth, RPC, provider, and AI templates; remove the generator rewrite that introduced the alias and match the Cloudflare public-env export.

Use explicit Handlebars conditions and JavaScript URL expressions in the templates, without custom URL helpers or SafeString code generation. Only generate URL resolvers for combined Vercel or Docker deployments. Other clients use their configured public server URL directly; Vercel-specific environment handling is emitted only for Vercel. Keep Docker’s internal SSR server URL. Remove the unnecessary createConfiguredAuth alias from singleton services, retaining it where a local createAuth factory requires a distinct name.

Verification:

  • bun run check, CLI build/publint, CLI source/test typechecks, generator typecheck.
  • CLI suite: 761 passed, 48 opt-in tests skipped, zero failures.
  • Generated Svelte auth/todo/AI and Solid self/Cloudflare projects: install, typechecks, and build passed.
  • Fresh TanStack Router + Hono + tRPC + Better Auth + SQLite/Drizzle project generated through the built CLI in ~/dev/test: install, schema push, typecheck, and production build passed.
  • Playwright against that generated app: rendered home, signup, authenticated dashboard/private RPC, and todo creation/toggle succeeded; auth and RPC requests returned 200. This is local browser validation, not a live deployment or exhaustive runtime coverage of every template combination.
  • Added generated-client execution checks for browser/SSR URL selection across normal, Vercel, and Docker configurations.

Varlock references: Vite integration and monorepo guide.

Summary by CodeRabbit

  • Bug Fixes

    • Improved generated configuration across web and native platforms by standardizing environment access.
    • Corrected authentication, RPC, AI, Convex, and payment URLs across supported deployment combinations.
    • Improved server URL handling for Vercel, Docker, Cloudflare, self-hosted, and local deployments.
    • Corrected generated authentication service setup for non-Cloudflare deployments.
  • Tests

    • Expanded coverage for deployment-specific client URLs and native authentication return URLs.

@vercel

vercel Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
create-better-t-stack-web Ready Ready Preview Sep 14, 2026 1:57pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-14T13:53:44.488697Z 686b713 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 2130e3f0-a19b-4ec2-9e28-3fe96a3461dc

📥 Commits

Reviewing files that changed from the base of the PR and between 686b713 and 9f4e021.

⛔ Files ignored due to path filters (1)
  • packages/template-generator/src/templates.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing (11)
  • packages/template-generator/src/core/template-processor.ts
  • packages/template-generator/templates/api/orpc/web/astro/src/lib/orpc.ts.hbs
  • packages/template-generator/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs
  • packages/template-generator/templates/api/orpc/web/solid/src/utils/orpc.ts.hbs
  • packages/template-generator/templates/api/orpc/web/svelte/src/lib/orpc.ts.hbs
  • packages/template-generator/templates/api/trpc/web/react/base/src/utils/trpc.ts.hbs
  • packages/template-generator/templates/auth/better-auth/web/astro/src/lib/auth-client.ts.hbs
  • packages/template-generator/templates/auth/better-auth/web/react/base/src/lib/auth-client.ts.hbs
  • packages/template-generator/templates/auth/better-auth/web/svelte/src/lib/auth-client.ts.hbs
  • packages/template-generator/templates/env/auth-client.ts.hbs
  • packages/template-generator/templates/frontend/react/tanstack-start/src/router.tsx.hbs

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


Walkthrough

Changes

Environment and URL generation

Layer / File(s) Summary
Generated ENV binding migration
packages/template-generator/processors/..., packages/template-generator/templates/...
Generated environment imports and references now use ENV across frontend, authentication, API, and AI templates.
Deployment-aware client URLs
packages/template-generator/src/core/template-processor.ts, packages/template-generator/templates/api/..., packages/template-generator/templates/auth/...
Server URL helpers now apply only to matching Vercel or Docker deployments. Other generated clients strip trailing slashes or use the configured URL directly.
Conditional authentication service generation
packages/template-generator/templates/env/services.ts.hbs
Cloudflare paths retain the configured-auth alias. Other paths import and invoke createAuth directly.
Deployment URL validation
apps/cli/test/auth.test.ts, apps/cli/test/cloudflare-db-clients.test.ts, apps/cli/test/deployment.test.ts
Tests update generated ENV and authentication expectations and cover client URL selection across deployment, frontend, backend, and runtime combinations.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to b06a6

The generated ENV migration and deployment-aware URL selection have no identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files. (10 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: preserving Varlock ENV access and limiting deployment URL handling in templates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files. (10 skipped: 10 unsupported.)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AmanVarshney01
AmanVarshney01 enabled auto-merge (squash) September 14, 2026 13:57
@AmanVarshney01
AmanVarshney01 merged commit 57afcd9 into main Sep 14, 2026
11 checks passed
@AmanVarshney01
AmanVarshney01 deleted the fix/template-client-deployment-wiring branch September 14, 2026 14:00

This branch was successfully deployed

1 active deployment
Preview — b06a6dca Deployed Sep 14, 2026 by vercel[bot]
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