fix(compat): cannot read property setLegacyMiddleware of undefined (#82)

This commit is contained in:
Xin Du (Clark) 2021-01-24 19:18:20 +00:00 committed by GitHub
parent 2d0ff10892
commit 67a82a7ab9

View File

@ -48,7 +48,9 @@ export default function nuxt2CompatModule () {
nuxt.hook('modules:done', () => {
const { middleware, legacyMiddleware } =
resolveMiddleware(nuxt.options.serverMiddleware, nuxt.resolver.resolvePath)
nuxt.server.setLegacyMiddleware(legacyMiddleware)
if (nuxt.server) {
nuxt.server.setLegacyMiddleware(legacyMiddleware)
}
nitroContext.middleware.push(...middleware)
nitroDevContext.middleware.push(...middleware)
})