🌐 AI搜索 & 代理 主页
Skip to content

Commit d6df732

Browse files
authored
fix(nuxt): make middleware _path property configurable for HMR (#33379)
1 parent 011c13e commit d6df732

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/nuxt/src/core/templates.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export const middlewareTemplate: NuxtTemplate = {
345345
: [
346346
`const _globalMiddleware = ${genObjectFromRawEntries(globalMiddleware.map(mw => [reverseResolveAlias(mw.path, alias).pop() || mw.path, genSafeVariableName(mw.name)]))}`,
347347
`for (const path in _globalMiddleware) {`,
348-
` Object.defineProperty(_globalMiddleware[path], '_path', { value: path })`,
348+
` Object.defineProperty(_globalMiddleware[path], '_path', { value: path, configurable: true })`,
349349
`}`,
350350
`export const globalMiddleware = Object.values(_globalMiddleware)`,
351351
`const _namedMiddleware = ${genArrayFromRaw(namedMiddleware.map(mw => ({
@@ -356,7 +356,7 @@ export const middlewareTemplate: NuxtTemplate = {
356356
`for (const mw of _namedMiddleware) {`,
357357
` const i = mw.import`,
358358
` mw.import = () => i().then(r => {`,
359-
` Object.defineProperty(r.default || r, '_path', { value: mw.path })`,
359+
` Object.defineProperty(r.default || r, '_path', { value: mw.path, configurable: true })`,
360360
` return r`,
361361
` })`,
362362
`}`,

0 commit comments

Comments
 (0)