mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
fix(server): fix HMR issue with serverMiddleware when router.base
is set (#8593)
This commit is contained in:
parent
c0732e2fe4
commit
1405968d89
@ -199,6 +199,11 @@ export default class Server {
|
||||
middleware = this._requireMiddleware(middleware)
|
||||
}
|
||||
|
||||
// #8584
|
||||
// shallow clone the middleware before any change is made,
|
||||
// in case any following mutation breaks when applied repeatedly.
|
||||
middleware = Object.assign({}, middleware)
|
||||
|
||||
// Normalize handler to handle (backward compatibility)
|
||||
if (middleware.handler && !middleware.handle) {
|
||||
middleware.handle = middleware.handler
|
||||
@ -271,6 +276,10 @@ export default class Server {
|
||||
middleware.route = fallbackRoute
|
||||
}
|
||||
|
||||
// #8584
|
||||
// save the original route before applying defaults
|
||||
middleware._originalRoute = middleware.route
|
||||
|
||||
// Resolve final route
|
||||
middleware.route = (
|
||||
(middleware.prefix !== false ? this.options.router.base : '') +
|
||||
@ -313,7 +322,13 @@ export default class Server {
|
||||
this.unloadMiddleware(serverStackItem)
|
||||
|
||||
// Resolve middleware
|
||||
const { route, handle } = this.resolveMiddleware(middleware, serverStackItem.route)
|
||||
const { route, handle } = this.resolveMiddleware(
|
||||
middleware,
|
||||
// #8584 pass the original route as fallback
|
||||
serverStackItem.handle._middleware
|
||||
? serverStackItem.handle._middleware._originalRoute
|
||||
: serverStackItem.route
|
||||
)
|
||||
|
||||
// Update serverStackItem
|
||||
serverStackItem.handle = handle
|
||||
|
Loading…
Reference in New Issue
Block a user