Repository navigation
fix(auth): match the dev better-auth client aliases exactly - #587
Merged
Merged
Conversation
With auth on, `vp dev` aliases `better-auth/client`, `/react`, `/vue`, `/svelte` and `/solid` to files in Void's own better-auth. A string alias also matches every deeper path, so `better-auth/client/plugins` (where `adminClient()` and the other client plugins live) became `.../dist/client/index.mjs/plugins`, and apps using a client plugin failed in dev on both the client and SSR. Builds have no alias and were fine. Use an anchored RegExp for each alias, which is Vite's only exact match. The five exact ids resolve as before; deeper subpaths resolve normally. Fixes #565 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://fix-better-auth-alias-subpaths-void-cloud.voidzero-docs.workers.dev (commit 67d306e)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
cpojer
reviewed
Oct 26, 2026
cpojer
previously approved these changes
Oct 26, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #565
Problem
With auth on,
vp devaliases five better-auth subpaths to files in Void's own copy of better-auth. Each alias used a stringfind, and in Vite a stringfindalso matches every deeper path:So any app that passes a Better Auth client plugin (
adminClient(),organizationClient(), …) tocreateAuthClientbroke in dev:Failed to resolve import "better-auth/client/plugins";No such module …).vp buildadds no alias, so it was fine.Fix
Each
findis now an anchored RegExp,^better-auth/<sub>$. Vite's alias API has only two kinds offind: a string, which also matches deeper paths, or a RegExp. So a RegExp is the only way to get an exact match. The repo already does the same ({ find: /^void$/ }incli/wrapper.ts).The five exact ids get the same replacement in every Vite step that reads
resolve.alias:vite:pre-alias;So the cold-cache reload protection from #24 (the reason the aliases exist) is kept.
Checks
New test in
plugin-routing.test.ts. It starts a real Vite dev server with auth on and resolves:better-auth/clientand/reactfrom an app file, which has no better-auth of its own. They resolve only through the aliases, to Void's copy.better-auth/client/pluginsfrom inside the package. It resolves todist/client/plugins/index.mjs.Mutation check: the test fails with the old string
findand with no aliases at all.Scratch app from the issue: a React pages app, auth on,
adminClient()frombetter-auth/client/plugins, cold cache,vp dev.voidtypecheck, lint and fmt pass. Affected tests (vp run test, 508 files) pass.Not changed here
client/pluginsis not pinned to Void's copy. The issue mentions this as optional. Without it, the user's own better-auth providesclient/plugins, as invp build, and Vite discovers it like any other dependency. That costs one optimizer reload on the first cold-cache page that imports it. Pinning would point the import at Void's better-auth version instead of the one the app installed. That's a product decision, so I left it out.🤖 Generated with Claude Code