mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 09:33:54 +00:00
fix(nitro): pass resolved handlers to the nitro config (#4263)
This commit is contained in:
parent
2ca704641b
commit
0d5ec20a4b
@ -56,6 +56,9 @@ export async function setupNitroBridge () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resolve Handlers
|
||||||
|
const { handlers, devHandlers } = await resolveHandlers(nuxt)
|
||||||
|
|
||||||
// Resolve config
|
// Resolve config
|
||||||
const _nitroConfig = (nuxt.options as any).nitro || {} as NitroConfig
|
const _nitroConfig = (nuxt.options as any).nitro || {} as NitroConfig
|
||||||
const nitroConfig: NitroConfig = defu(_nitroConfig, <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')),
|
scanDirs: nuxt.options._layers.map(layer => join(layer.config.srcDir, 'server')),
|
||||||
renderer: resolve(distDir, 'runtime/nitro/renderer'),
|
renderer: resolve(distDir, 'runtime/nitro/renderer'),
|
||||||
nodeModulesDirs: nuxt.options.modulesDir,
|
nodeModulesDirs: nuxt.options.modulesDir,
|
||||||
handlers: [],
|
handlers,
|
||||||
devHandlers: [],
|
devHandlers: [],
|
||||||
runtimeConfig: {
|
runtimeConfig: {
|
||||||
...nuxt.options.runtimeConfig,
|
...nuxt.options.runtimeConfig,
|
||||||
@ -231,8 +234,6 @@ export async function setupNitroBridge () {
|
|||||||
// Setup handlers
|
// Setup handlers
|
||||||
const devMidlewareHandler = dynamicEventHandler()
|
const devMidlewareHandler = dynamicEventHandler()
|
||||||
nitro.options.devHandlers.unshift({ handler: devMidlewareHandler })
|
nitro.options.devHandlers.unshift({ handler: devMidlewareHandler })
|
||||||
const { handlers, devHandlers } = await resolveHandlers(nuxt)
|
|
||||||
nitro.options.handlers.push(...handlers)
|
|
||||||
nitro.options.devHandlers.push(...devHandlers)
|
nitro.options.devHandlers.push(...devHandlers)
|
||||||
nitro.options.handlers.unshift({
|
nitro.options.handlers.unshift({
|
||||||
route: '/__nuxt_error',
|
route: '/__nuxt_error',
|
||||||
|
@ -12,6 +12,9 @@ import { distDir } from '../dirs'
|
|||||||
import { ImportProtectionPlugin } from './plugins/import-protection'
|
import { ImportProtectionPlugin } from './plugins/import-protection'
|
||||||
|
|
||||||
export async function initNitro (nuxt: Nuxt) {
|
export async function initNitro (nuxt: Nuxt) {
|
||||||
|
// Resolve handlers
|
||||||
|
const { handlers, devHandlers } = await resolveHandlers(nuxt)
|
||||||
|
|
||||||
// Resolve config
|
// Resolve config
|
||||||
const _nitroConfig = ((nuxt.options as any).nitro || {}) as NitroConfig
|
const _nitroConfig = ((nuxt.options as any).nitro || {}) as NitroConfig
|
||||||
const nitroConfig: NitroConfig = defu(_nitroConfig, <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')),
|
scanDirs: nuxt.options._layers.map(layer => join(layer.config.srcDir, 'server')),
|
||||||
renderer: resolve(distDir, 'core/runtime/nitro/renderer'),
|
renderer: resolve(distDir, 'core/runtime/nitro/renderer'),
|
||||||
nodeModulesDirs: nuxt.options.modulesDir,
|
nodeModulesDirs: nuxt.options.modulesDir,
|
||||||
handlers: [],
|
handlers,
|
||||||
devHandlers: [],
|
devHandlers: [],
|
||||||
baseURL: nuxt.options.app.baseURL,
|
baseURL: nuxt.options.app.baseURL,
|
||||||
runtimeConfig: {
|
runtimeConfig: {
|
||||||
@ -117,8 +120,6 @@ export async function initNitro (nuxt: Nuxt) {
|
|||||||
// Setup handlers
|
// Setup handlers
|
||||||
const devMidlewareHandler = dynamicEventHandler()
|
const devMidlewareHandler = dynamicEventHandler()
|
||||||
nitro.options.devHandlers.unshift({ handler: devMidlewareHandler })
|
nitro.options.devHandlers.unshift({ handler: devMidlewareHandler })
|
||||||
const { handlers, devHandlers } = await resolveHandlers(nuxt)
|
|
||||||
nitro.options.handlers.push(...handlers)
|
|
||||||
nitro.options.devHandlers.push(...devHandlers)
|
nitro.options.devHandlers.push(...devHandlers)
|
||||||
nitro.options.handlers.unshift({
|
nitro.options.handlers.unshift({
|
||||||
route: '/__nuxt_error',
|
route: '/__nuxt_error',
|
||||||
|
Loading…
Reference in New Issue
Block a user