Skip to content

fix(deploy): upload dist/client for a Vite app built with void - #907

Merged
Brooooooklyn merged 5 commits into
mainfrom
fix/static-void-app-deploy
Nov 24, 2026
Merged

Brooooooklyn merged 5 commits into
mainfrom
fix/static-void-app-deploy

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

How this was found

We tested the security-audits work (PR #886) end to end on a live self-hosted Void platform. One test app was a Vite app that uses voidPlugin() and has no backend. Deploying it broke the site and made server files public. The bug is not part of the security-audits feature, and the same code is on main, so it gets its own PR.

Repro

  1. Make an app whose package.json has vite-plus and void.
  2. vite.config.ts uses plugins: [voidPlugin()].
  3. Add only index.html and main.js. No routes/, pages/, or other backend folders.
  4. Run void deploy to a Void platform. The CLI prints "Static SPA deploy".
  5. Make the project public and fetch it.
Request Expected Actual (main)
/ 200, index.html 404
/client/index.html not a path 200
/ssr/index.js.map not uploaded 200, the full server source map (about 324 KB, with sourcesContent)
/ssr/wrangler.json not uploaded 200

Uploaded files on main: client/index.html, client/assets/*, client/.vite/manifest.json, ssr/index.js, ssr/index.js.map, ssr/wrangler.json, ssr/.vite/manifest.json.

Side effect: the server bundle has a new random build key on every build (packages/void/src/router/compile.ts:881-883), so a redeploy of unchanged code uploaded a changed ssr/index.js.map and made a new deployment (and, with security audits on, a new scan) each time.

Root cause

void deploy
  └─ detectPreset(root)                 packages/void/src/cli/preset.ts
       1. --dir?            no
       2. SSG dep?          no
       3. backend files?    no
       4. vite in deps?     yes  ->  outputDir = dist   <-- wrong for voidPlugin

packages/void/src/cli/preset.ts:277-285 (step 4) always used dist. That is right for plain Vite, which writes dist/index.html. But voidPlugin() splits the build:

dist/
├─ client/   browser files, index.html   <- should be uploaded
└─ ssr/      server bundle, .map, wrangler.json   <- must not be uploaded

So the whole dist/ went up, and / had no index.html.

The same step is used by the managed platform path (cli/deploy.ts), the native Cloudflare static path (resolveCloudflareStaticPreset in cli/deploy-cloudflare-static.ts), and by configured inference.appType: "spa" | "static" without outputDir (resolveStaticDeployPreset in cli/deploy-helpers.ts). All three get the fix.

Fix

In step 4, when the package depends on void, use dist/client. Plain Vite apps keep dist. void init adds voidPlugin() to Vite apps, so a void dependency means the build has the split layout. App type stays spa, same as before; only the folder changes.

The docs for inference.outputDir now say the default is dist/client for projects that depend on void.

Tests

  • packages/void/test/unit/preset.test.ts
    • uploads only dist/client for a Vite app built with void and no backend: vite-plus + void, only index.html + main.js -> dist/client, spa.
    • uses dist/client for a configured static app built with void: inference.appType: "spa" with no outputDir -> dist/client.
    • Both fail on main (they get dist) and pass with the fix. The plain Vite and Vite+ tests still expect dist.
  • vp run test: all groups pass except one timeout in platform/packages/api/test/integration/admin-dashboard.test.ts ("keeps runtime-log client fields when navigating away and back", 5 s, dashboard UI, not touched here). It passes when run alone.
  • vp fmt --check, vp lint, and the void package typecheck pass. In a fresh worktree, vp check also reports missing playground/*/.void/tsconfig.json files, which are generated by a playground build and are unrelated.

🤖 Generated with Claude Code

A Vite app that depends on `void` builds with voidPlugin(), which writes
browser files to dist/client and the server bundle, its source map and
wrangler.json to dist/ssr. With no backend files, detectPreset step 4
picked `dist` as the static output, so `void deploy` published the
server files and `/` returned 404 (index.html sat at /client/index.html).

Pick dist/client in that case. A plain Vite app keeps `dist`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T22:15:07.886979Z 154d3ca 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.

@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: 154d3ca016

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

Comment thread packages/void/src/cli/preset.ts Resolved
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-static-void-app-deploy-void-cloud.voidzero-docs.workers.dev (commit ff6c9bb)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://db885d44-void-cloud.voidzero-docs.workers.dev ff6c9bb 2026-11-24T05:40:25.660Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://9d7f2846-void-cloud.voidzero-docs.workers.dev 2d6a37b 2026-11-24T04:41:24.396Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://81ed72a4-void-cloud.voidzero-docs.workers.dev 8368695 2026-11-24T03:54:15.278Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://26b73b3a-void-cloud.voidzero-docs.workers.dev 74a4234 2026-11-24T03:12:40.360Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://5e09c224-void-cloud.voidzero-docs.workers.dev 154d3ca 2026-11-23T22:14:08.856Z Visit the dashboard ↗

Brooooooklyn and others added 4 commits November 24, 2026 11:11
…in()

A project can install void for its CLI alone and keep Vite's plain dist
output. Choosing dist/client from the dependency made those deploys fail
with a missing output directory. Read the Vite config and use dist/client
only when it imports voidPlugin from void.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eploy

# Conflicts:
#	packages/void/src/cli/preset.ts
@Brooooooklyn
Brooooooklyn merged commit ce231af into main Nov 24, 2026
21 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/static-void-app-deploy branch November 24, 2026 06:00
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