{{ route.path }}
+ ${stack.map(i => `${i.text}`).join('\n')}
- `
+ ? `${stack.map(i => `${i.text}`).join('\n')}
`
: ''
}
- res.statusCode = error.statusCode || 500
- res.statusMessage = error.statusMessage || 'Internal Server Error'
+ res.statusCode = errorObject.statusCode
+ res.statusMessage = errorObject.statusMessage
// Console output
if (!is404) {
@@ -56,8 +56,9 @@ export function handleError (error, req: IncomingMessage, res: ServerResponse) {
}
// HTML response
- const errorTemplate = is404 ? error404 : (isDev ? errorDev : error500)
- const html = errorTemplate(errorObject)
+ const url = withQuery('/_nitro/__error', errorObject)
+ const html = await $fetch(url).catch(() => errorObject.statusMessage)
+
res.setHeader('Content-Type', 'text/html;charset=UTF-8')
res.end(html)
}
diff --git a/packages/nitro/src/runtime/server/index.ts b/packages/nitro/src/runtime/server/index.ts
index ce38f7c0b2..feb628f949 100644
--- a/packages/nitro/src/runtime/server/index.ts
+++ b/packages/nitro/src/runtime/server/index.ts
@@ -1,4 +1,4 @@
-import { createApp, useBase } from 'h3'
+import { createApp, lazyHandle, useBase } from 'h3'
import { createFetch, Headers } from 'ohmyfetch'
import destr from 'destr'
import { createCall, createFetch as createLocalFetch } from 'unenv/runtime/fetch/index'
@@ -13,9 +13,12 @@ const app = createApp({
onError: handleError
})
+const renderMiddleware = lazyHandle(() => import('../app/render').then(e => e.renderMiddleware))
+
+app.use('/_nitro', renderMiddleware)
app.use(timingMiddleware)
app.use(serverMiddleware)
-app.use(() => import('../app/render').then(e => e.renderMiddleware), { lazy: true })
+app.use(renderMiddleware)
export const stack = app.stack
export const handle = useBase(baseURL(), app)
diff --git a/packages/nitro/src/server/dev.ts b/packages/nitro/src/server/dev.ts
index b0e10ae6ee..fa54419587 100644
--- a/packages/nitro/src/server/dev.ts
+++ b/packages/nitro/src/server/dev.ts
@@ -2,7 +2,7 @@ import { Worker } from 'worker_threads'
import { IncomingMessage, ServerResponse } from 'http'
import { existsSync, promises as fsp } from 'fs'
-import { loading as loadingTemplate } from '@nuxt/design'
+import { loading as loadingTemplate } from '@nuxt/ui-templates'
import chokidar, { FSWatcher } from 'chokidar'
import debounce from 'p-debounce'
import { promisifyHandle, createApp, Middleware, useBase } from 'h3'
diff --git a/packages/nuxi/package.json b/packages/nuxi/package.json
index 22fcf9bdc2..37802b889b 100644
--- a/packages/nuxi/package.json
+++ b/packages/nuxi/package.json
@@ -17,9 +17,9 @@
"prepack": "unbuild"
},
"devDependencies": {
- "@nuxt/design": "0.1.5",
"@nuxt/kit": "3.0.0",
"@nuxt/schema": "3.0.0",
+ "@nuxt/ui-templates": "npm:@nuxt/ui-templates-edge@latest",
"@types/clear": "^0",
"@types/mri": "^1.1.1",
"@types/rimraf": "^3",
diff --git a/packages/nuxi/src/commands/dev.ts b/packages/nuxi/src/commands/dev.ts
index e08bb5d685..faf79451fb 100644
--- a/packages/nuxi/src/commands/dev.ts
+++ b/packages/nuxi/src/commands/dev.ts
@@ -86,7 +86,7 @@ export default defineNuxtCommand({
dLoad(true, `Directory \`${dir}/\` ${event === 'addDir' ? 'created' : 'removed'}`)
}
} else if (isFileChange) {
- if (file.match(/app\.(js|ts|mjs|jsx|tsx|vue)$/)) {
+ if (file.match(/(app|error)\.(js|ts|mjs|jsx|tsx|vue)$/)) {
dLoad(true, `\`${relative(rootDir, file)}\` ${event === 'add' ? 'created' : 'removed'}`)
}
}
diff --git a/packages/nuxi/src/utils/server.ts b/packages/nuxi/src/utils/server.ts
index 43aaf5223e..015386cefa 100644
--- a/packages/nuxi/src/utils/server.ts
+++ b/packages/nuxi/src/utils/server.ts
@@ -1,6 +1,6 @@
import type { RequestListener } from 'http'
import type { ListenOptions } from 'listhen'
-import { loading } from '@nuxt/design'
+import { loading } from '@nuxt/ui-templates'
export function createServer (defaultApp?) {
const listener = createDynamicFunction(defaultApp || createLoadingHandler('Loading...'))
diff --git a/packages/nuxt3/package.json b/packages/nuxt3/package.json
index bc36929930..95ebfde32b 100644
--- a/packages/nuxt3/package.json
+++ b/packages/nuxt3/package.json
@@ -30,10 +30,10 @@
"prepack": "unbuild"
},
"dependencies": {
- "@nuxt/design": "^0.1.5",
"@nuxt/kit": "3.0.0",
"@nuxt/nitro": "3.0.0",
"@nuxt/schema": "3.0.0",
+ "@nuxt/ui-templates": "npm:@nuxt/ui-templates-edge@latest",
"@nuxt/vite-builder": "3.0.0",
"@vue/reactivity": "^3.2.31",
"@vue/shared": "^3.2.31",
diff --git a/packages/nuxt3/src/app/components/nuxt-error-page.vue b/packages/nuxt3/src/app/components/nuxt-error-page.vue
new file mode 100644
index 0000000000..1d14f6869d
--- /dev/null
+++ b/packages/nuxt3/src/app/components/nuxt-error-page.vue
@@ -0,0 +1,42 @@
+
+