Skip to content

fix(cli): keep env validation out of browser bundles - #1164

Merged
AmanVarshney01 merged 2 commits into
mainfrom
aman/fix-browser-env-validation
Aug 13, 2026
Merged

AmanVarshney01 merged 2 commits into
mainfrom
aman/fix-browser-env-validation

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Aug 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • remove SKIP_ENV_VALIDATION from generated browser environment modules
  • limit the Docker validation bypass to images that contain a self-hosted server
  • pass NUXT_PUBLIC_SERVER_URL as a Docker build argument so Nuxt public env remains validated
  • add regression coverage and clarify the Docker environment behavior

Root cause

The shared browser env module read process.env.SKIP_ENV_VALIDATION. Vite shipped that expression to the browser, where process is unavailable, so SolidStart hydration crashed before the API status query could run.

Self-hosted SSR images still need the documented t3-env build bypass because their server modules are evaluated while building, before runtime secrets are injected. The bypass now stays in that server build context and is never referenced by browser code.

Verification

  • bun run check
  • bun run build
  • CLI suite: 655 passed, 29 skipped
  • focused deployment/frontend tests: 117 passed
  • generated SolidStart app verified in a real browser with API status connected
  • generated Nuxt Docker image built successfully with public env validation enabled

Summary by CodeRabbit

  • Bug Fixes

    • Docker deployments now validate public environment variables consistently across supported frontend frameworks.
    • Self-hosted server builds continue to support skipped validation where required, without applying it unnecessarily to other deployment types.
    • Nuxt deployments now correctly pass the public server URL during image builds and Compose setup.
  • Documentation

    • Clarified Docker configuration requirements, including runtime settings and database placeholders.

@vercel

vercel Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
create-better-t-stack-web Ready Ready Preview Aug 13, 2026 10:31am

Request Review

@AmanVarshney01
AmanVarshney01 enabled auto-merge (squash) August 13, 2026 10:31
@coderabbitai

coderabbitai Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d9e9d5e8-2f9f-4f5b-9a31-249039603a87

📥 Commits

Reviewing files that changed from the base of the PR and between f60412e and 202fb89.

⛔ Files ignored due to path filters (1)
  • packages/template-generator/src/templates.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing (13)
  • apps/cli/test/deployment.test.ts
  • apps/cli/test/frontend.test.ts
  • apps/web/content/docs/guides/docker.mdx
  • packages/template-generator/templates/deploy/docker/compose/docker-compose.yml.hbs
  • packages/template-generator/templates/deploy/docker/web/astro/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/nuxt/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/react/next/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/react/react-router/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/react/tanstack-router/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/react/tanstack-start/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/solid/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/svelte/Dockerfile.hbs
  • packages/template-generator/templates/packages/env/src/web.ts.hbs
💤 Files with no reviewable changes (3)
  • packages/template-generator/templates/packages/env/src/web.ts.hbs
  • packages/template-generator/templates/deploy/docker/web/react/react-router/Dockerfile.hbs
  • packages/template-generator/templates/deploy/docker/web/react/tanstack-router/Dockerfile.hbs

Walkthrough

Changes

Docker validation and frontend variables

Layer / File(s) Summary
Backend-specific validation policy
packages/template-generator/templates/packages/env/src/web.ts.hbs, packages/template-generator/templates/deploy/docker/web/*
Generated web environment validation no longer reads SKIP_ENV_VALIDATION. Docker templates emit the variable only for self-hosted backends.
Nuxt public URL wiring
packages/template-generator/templates/deploy/docker/compose/docker-compose.yml.hbs, packages/template-generator/templates/deploy/docker/web/nuxt/Dockerfile.hbs
Nuxt Docker builds pass NUXT_PUBLIC_SERVER_URL through Compose and Dockerfile build arguments.
Deployment and generation assertions
apps/cli/test/deployment.test.ts, apps/cli/test/frontend.test.ts, apps/web/content/docs/guides/docker.mdx
Tests verify validation settings, Nuxt URL propagation, and generated SolidStart environment output. Docker documentation describes the updated behavior.

Possibly related PRs

Mergeability Score: ⚪ Minimal · up to 202fb

The PR keeps environment validation out of browser bundles while preserving the required server-side Docker behavior, with no actionable merge-blocking risk remaining after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing environment validation from entering browser bundles.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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 merged commit dfaa5e5 into main Aug 13, 2026
3 checks passed
@AmanVarshney01
AmanVarshney01 deleted the aman/fix-browser-env-validation branch August 13, 2026 10:33

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8e54471e3

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

{{/if}}
{{/if}}
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
emptyStringAsUndefined: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Pass the Convex site URL into Docker builds

When Docker deployment is selected with Convex, Better Auth, and any supported React frontend, web env validation requires NEXT_PUBLIC_CONVEX_SITE_URL or VITE_CONVEX_SITE_URL, but the Compose template and corresponding Dockerfiles pass only the Convex cloud URL. Now that validation is no longer skipped, docker compose build deterministically fails for these configurations; add the site URL to the generated root Compose variables, build arguments, and Dockerfile ARG/ENV declarations.

Useful? React with 👍 / 👎.

context: .
dockerfile: apps/web/Dockerfile
{{#if (and (not (includes frontend "nuxt")) (or (and (ne backend "self") (ne backend "none") (ne backend "convex")) (eq backend "convex") (and (eq auth "clerk") (or (includes frontend "next") (includes frontend "react-router") (includes frontend "tanstack-router") (includes frontend "tanstack-start")))))}}
{{#if (or (and (ne backend "self") (ne backend "none") (ne backend "convex")) (eq backend "convex") (and (eq auth "clerk") (or (includes frontend "next") (includes frontend "react-router") (includes frontend "tanstack-router") (includes frontend "tanstack-start"))))}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Pass the Nuxt-prefixed Convex URL to the image

For frontend: nuxt, backend: convex, and webDeploy: docker, this widened condition now creates an args block, but the Convex branch emits VITE_CONVEX_URL while the Nuxt config validates NUXT_PUBLIC_CONVEX_URL; the Nuxt Dockerfile also has no corresponding Convex ARG/ENV. Because per-app .env files are excluded from the build context and validation is no longer bypassed, this supported image cannot build even when the intended Nuxt variable is configured. Add a Nuxt-specific Convex argument throughout Compose, the Dockerfile, and root build-argument env generation.

Useful? React with 👍 / 👎.

This branch was successfully deployed

1 active deployment
Preview — 202fb89d Deployed Aug 13, 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