Repository navigation
fix(onboard): serve embedded.js through Nuxt's Vite dev handler - #1130
Merged
Merged
Conversation
Deploying nuxt-devtools with
|
| Latest commit: |
daf70a6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0af6aeef.nuxt-devtools.pages.dev |
| Branch Preview URL: | https://fix-onboard-embedded-script.nuxt-devtools.pages.dev |
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.
Summary
When
@nuxt/devtoolsis not installed,nuxt devanswers/__devtools/embedded.jswith the app's HTML page (content-type: text/html). The browser then rejects the module script, so the onboarding button never shows up. This affects@nuxt/devtools-onboard@4.0.0-beta.6.The onboarding middleware was mounted at the root of the client Vite server. Nuxt's Vite dev handler only passes a request to Vite when some middleware is mounted on a path longer than
/. Otherwise it rewrites the URL to/__skip_vite/..., the middleware'sbasecheck fails, and the request falls through to the Nuxt renderer.The middleware is now mounted on
/__devtools, taken from the samebasepassed tocreateOnboarding. Connect strips the mount path, so the wrapper putsreq.originalUrlback before calling the onboarding middleware.The module test used a fake
middlewares.use(fn)that skipped connect's routing, so it could not catch this. It now mounts the module on a real Vite server in middleware mode. It also checks that Nuxt's routing rule (route.length > 1 && url.startsWith(route)) sends/__devtools/embedded.jsto Vite and that the script comes back as JavaScript. This addsviteas a devDependency of the package.Verification
pnpm vitest run packages/devtools-onboard: the new assertions pass. With the old mount restored,offers to install @nuxt/devtools when it is missingfails as expected.loads @nuxt/devtools when it is installedfails onmaintoo, with or without this change. It likely needs@nuxt/devtoolsbuilt first; not confirmed.pnpm eslint packages/devtools-onboard pnpm-workspace.yaml: clean.curl -i localhost:3000/__devtools/embedded.jsrepro againstnuxt devin the playground.This PR was created with the help of an agent.