fix(nitro): pass resolved handlers to the nitro config (#4263)

This commit is contained in:
Ahad Birang 2022-04-11 20:38:42 +02:00 committed by GitHub
parent 2ca704641b
commit 0d5ec20a4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -56,6 +56,9 @@ export async function setupNitroBridge () {
}
}
// Resolve Handlers
const { handlers, devHandlers } = await resolveHandlers(nuxt)
// Resolve config
const _nitroConfig = (nuxt.options as any).nitro || {} as NitroConfig
const nitroConfig: NitroConfig = defu(_nitroConfig, <NitroConfig>{
@ -67,7 +70,7 @@ export async function setupNitroBridge () {
scanDirs: nuxt.options._layers.map(layer => join(layer.config.srcDir, 'server')),
renderer: resolve(distDir, 'runtime/nitro/renderer'),
nodeModulesDirs: nuxt.options.modulesDir,
handlers: [],
handlers,
devHandlers: [],
runtimeConfig: {
...nuxt.options.runtimeConfig,
@ -231,8 +234,6 @@ export async function setupNitroBridge () {
// Setup handlers
const devMidlewareHandler = dynamicEventHandler()
nitro.options.devHandlers.unshift({ handler: devMidlewareHandler })
const { handlers, devHandlers } = await resolveHandlers(nuxt)
nitro.options.handlers.push(...handlers)
nitro.options.devHandlers.push(...devHandlers)
nitro.options.handlers.unshift({
route: '/__nuxt_error',

View File

@ -12,6 +12,9 @@ import { distDir } from '../dirs'
import { ImportProtectionPlugin } from './plugins/import-protection'
export async function initNitro (nuxt: Nuxt) {
// Resolve handlers
const { handlers, devHandlers } = await resolveHandlers(nuxt)
// Resolve config
const _nitroConfig = ((nuxt.options as any).nitro || {}) as NitroConfig
const nitroConfig: NitroConfig = defu(_nitroConfig, <NitroConfig>{
@ -23,7 +26,7 @@ export async function initNitro (nuxt: Nuxt) {
scanDirs: nuxt.options._layers.map(layer => join(layer.config.srcDir, 'server')),
renderer: resolve(distDir, 'core/runtime/nitro/renderer'),
nodeModulesDirs: nuxt.options.modulesDir,
handlers: [],
handlers,
devHandlers: [],
baseURL: nuxt.options.app.baseURL,
runtimeConfig: {
@ -117,8 +120,6 @@ export async function initNitro (nuxt: Nuxt) {
// Setup handlers
const devMidlewareHandler = dynamicEventHandler()
nitro.options.devHandlers.unshift({ handler: devMidlewareHandler })
const { handlers, devHandlers } = await resolveHandlers(nuxt)
nitro.options.handlers.push(...handlers)
nitro.options.devHandlers.push(...devHandlers)
nitro.options.handlers.unshift({
route: '/__nuxt_error',