Skip to content

fix(node): serve devtools under base path - #662

Open
huang-julien wants to merge 1 commit into
vitejs:mainfrom
huang-julien:fix/base_path
Open

huang-julien wants to merge 1 commit into
vitejs:mainfrom
huang-julien:fix/base_path

Conversation

@huang-julien

@huang-julien huang-julien commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

Hey 👋

This PR makes the dev-mode embedded loader respect Vite's base and makes the hub answer under base too.

Why

When working on the Storybook integration, I noticed that the Storybook preview was mounting the host app's dock instead of its own which ends up in an infinite reload.

Storybook's Vite plugin starts a second Vite server in middlewareMode with base: '/storybook/', and the parent server strips /storybook before handing requests over. That inner server has its own hub at /storybook/__devtools/, but its pages still load /__devtools/embedded.js, which is the outer hub (or a 404 if there's none). If the host registers an iframe dock pointing at Storybook, it nests itself endlessly.

The issue lies in DevToolsInjection: it only adds config.base when config.command === 'build', so in serve mode the loader always points at the root.

Reporudction

Screen.Recording.2026-12-02.at.13.21.37.mov
git clone https://github.com/storybookjs/mealdrop.git
git checkout julien/vite-plugin-devtools
yarn 
yarn start

open the devtools dock of storybook. it will be linked to the actual devtool of the app rather thean the nested storybook.

Fix screenshot

image

You can see that the devtools in storybook isn't the one from the app as it doesn't dock Storybook within Storybook

Linked Issues

Additional context

@pkg-pr-new

pkg-pr-new Bot commented Dec 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vitejs/devtools

npm i https://pkg.pr.new/@vitejs/devtools@662

@vitejs/devtools-kit

npm i https://pkg.pr.new/@vitejs/devtools-kit@662

@vitejs/devtools-oxc

npm i https://pkg.pr.new/@vitejs/devtools-oxc@662

@vitejs/devtools-rolldown

npm i https://pkg.pr.new/@vitejs/devtools-rolldown@662

@vitejs/devtools-vite

npm i https://pkg.pr.new/@vitejs/devtools-vite@662

@vitejs/devtools-vite-task

npm i https://pkg.pr.new/@vitejs/devtools-vite-task@662

@vitejs/devtools-vitest

npm i https://pkg.pr.new/@vitejs/devtools-vitest@662

commit: 190507d

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