Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dev): prepend baseURL for vite hmr ws upgrade #370

Merged
merged 3 commits into from Mar 20, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/utils/dev.ts
Expand Up @@ -244,14 +244,15 @@ class NuxtDevServer extends EventEmitter {
this.listener.server.on(
'upgrade',
async (req: any, socket: any, head: any) => {
if (
req.url.startsWith(
this._currentNuxt?.options.app.buildAssetsDir /* /_nuxt/ */,
)
) {
const nuxt = this._currentNuxt
if (!nuxt) return
const viteHmrPath = (
nuxt.options.app.baseURL + nuxt.options.app.buildAssetsDir
).replace(/\/\//g, '/')
antfu marked this conversation as resolved.
Show resolved Hide resolved
if (req.url.startsWith(viteHmrPath)) {
return // Skip for Vite HMR
}
await this._currentNuxt?.server.upgrade(req, socket, head)
await nuxt.server.upgrade(req, socket, head)
pi0 marked this conversation as resolved.
Show resolved Hide resolved
},
)
}
Expand Down