Skip to content

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

Open
Brooooooklyn wants to merge 1 commit into
mainfrom
fix/static-void-app-deploy
Open

Brooooooklyn wants to merge 1 commit 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".

* without an `index.html`.
*/
function viteSpaOutputDir(pkg: Record<string, unknown>): string {
return hasPackageDependency(pkg, 'void') ? 'dist/client' : 'dist';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Distinguish CLI installation from use of the Vite plugin

For a plain Vite SPA that installs void to use its deployment CLI but does not enable voidPlugin(), this changes the upload directory to dist/client even though the build still produces dist/index.html. Both deploy-managed-static.ts and deploy-cloudflare-static.ts reject the nonexistent output directory after a successful build, so previously working static deployments now fail. A void dependency does not establish that its Vite plugin runs; determine whether the split build layout is actually used before selecting dist/client, while retaining dist for CLI-only installations.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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