Skip to content

fix(vite): defer auth to the host when bridging a devframe#132

Merged
antfu merged 1 commit into
mainfrom
feat/hosted-adapter-defers-auth
Jul 23, 2026
Merged

fix(vite): defer auth to the host when bridging a devframe#132
antfu merged 1 commit into
mainfrom
feat/hosted-adapter-defers-auth

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

What

Bridging a devframe into a host (a Vite/Nuxt app, or a hub) is a hosted deployment: the host owns the origin and authentication. Yet viteDevBridge's bridge mode delegated to createDevServer, which honors def.cli.auth (default true) — so a plugin mounted this way spun up its own interactive OTP gate and printed an auth banner, triggering standalone self-auth in a context where the host should manage it. This contradicted the contract documented on every built-in plugin: "Hosted adapters manage their own auth and ignore this." Only og had noticed, working around it with an ad-hoc auth: false option.

Change

  • viteDevBridge now runs its side-car RPC server with the bridged devframe's auth gate off by default (ignoring cli.auth), overridable per-mount via a new auth?: boolean | DevframeAuthHandler option.
  • createDevServer gains a matching auth override (highest precedence in the resolution) so hosted adapters can force the outcome; the --no-auth flag still wins.
  • Removed og's now-obsolete auth workaround — OgVitePluginOptions is just ViteDevBridgeOptions and forwards through.

Because git, inspect, a11y, terminals, code-server, data-inspector, messages, og, and the Nuxt module all route through viteDevBridge, every built-in plugin now uniformly defers auth to the host with no per-plugin code. Standalone behavior is unchanged — running a plugin via its CLI still gates by default.

Verification

  • Added 3 tests: auth option forces the gate off over a gated cli.auth; forces it on over cli.auth: false; --no-auth still wins over auth: true.
  • Updated 3 tsnapi public-API snapshots for the new options.
  • pnpm build, pnpm typecheck, pnpm lint, pnpm test all green (855 tests).

This PR was created with the help of an agent.

A bridged devframe is a hosted deployment: the host app owns the origin
and authentication. Stop the plugin's own OTP gate from firing in that
context so a plugin mounted in a hub (or any host) never triggers its
standalone auth, matching the documented hosted-adapter contract.

viteDevBridge now runs its side-car RPC server with the plugin's auth
gate off by default (ignoring cli.auth), overridable per-mount via a new
`auth` option; createDevServer gains a matching `auth` override so hosted
adapters can force the resolution while --no-auth still wins.
@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit 4d59856
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a61ab203b9869000871d90c
😎 Deploy Preview https://deploy-preview-132--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@antfu
antfu merged commit e170f26 into main Jul 23, 2026
12 checks passed
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.

2 participants