Skip to content

Commit 4449f09

Browse files
authored
feat(devtools): proxy client __connection.json to hub in standalone dev (#1070)
1 parent a241951 commit 4449f09

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎packages/devtools/client/nuxt.config.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,20 @@ export default defineNuxtConfig({
140140
hmr: {
141141
clientPort: process.env.PORT ? +process.env.PORT : undefined,
142142
},
143+
// Local standalone dev only (`pnpm dev` -> `nuxi dev client`): this app
144+
// dogfoods the DevTools module on itself, so the Vite DevTools hub serves
145+
// the devframe connection meta at `/__devtools/__connection.json`. But the
146+
// client SPA (RPC client) resolves `__connection.json` relative to its
147+
// current route (e.g. `/__nuxt_devtools__/client/modules/__connection.json`),
148+
// which the hub never serves. Proxy those relative lookups back to the hub
149+
// so the standalone client can connect to a live RPC backend.
150+
proxy: {
151+
'^/__nuxt_devtools__/client/.*__connection\\.json(\\?.*)?$': {
152+
target: `http://localhost:${process.env.PORT||3000}`,
153+
changeOrigin: true,
154+
rewrite: ()=>'/__devtools/__connection.json',
155+
},
156+
},
143157
},
144158
},
145159

0 commit comments

Comments
 (0)