@nuxt/docs-nightly 5.0.0-2611181518-326ec2d → 5.0.0-2611190848-45e20ca
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1153,6 +1153,8 @@ export default defineNuxtConfig({
|
|
|
1153
1153
|
})
|
|
1154
1154
|
```
|
|
1155
1155
|
|
|
1156
|
+
The build warns with `NUXT_B9014` and lists the suffixes to add. Nitro v2 kept these suffixes as part of the name, so with [`nitroLegacy.config`](#your-own-server-directory) on, Nuxt adds them to `nitro.scanSuffixes` for you and lists the files with `NUXT_B9013`.
|
|
1157
|
+
|
|
1156
1158
|
#### Route Rule Types Move to `h3/rules`
|
|
1157
1159
|
|
|
1158
1160
|
Nitro v3 builds route rules on h3, so custom route rules are declared there rather than on `nitro/types`. `NitroRouteConfig` and `NitroRouteRules` are still exported as deprecated aliases, but they are now type aliases rather than interfaces, so augmenting them fails with `TS2300: Duplicate identifier`.
|
|
@@ -1203,7 +1205,7 @@ Nuxt now generates `.nuxt/tsconfig.server.json` itself, as one of the tsconfigs
|
|
|
1203
1205
|
|
|
1204
1206
|
- **Nitro plugin imports**: Use `import { definePlugin } from 'nitro'`, which is now required by default. See [Server Auto-Imports Are Now Opt-In](#server-auto-imports-are-now-opt-in).
|
|
1205
1207
|
- **Route rule helpers**: `basicAuth` route rules are replaced by middleware, and a new `cors` rule replaces manual CORS wiring. See the [Nitro migration guide](https://nitro.build/docs/migration) for the runtime details.
|
|
1206
|
-
- **Runtime hooks**: `nitroApp.hooks.hook('beforeResponse', ...)`, `nitroApp.hooks.hook('afterResponse', ...)` and `nitroApp.hooks.hook('render:response', ...)` have been replaced by `nitroApp.hooks.hook('response', ...)`. The `render:before` hook is
|
|
1208
|
+
- **Runtime hooks**: `nitroApp.hooks.hook('beforeResponse', ...)`, `nitroApp.hooks.hook('afterResponse', ...)` and `nitroApp.hooks.hook('render:response', ...)` have been replaced by `nitroApp.hooks.hook('response', ...)`. The `render:before` hook is emitted only while the [Nitro v2 compatibility layer](#nitro-v2-compatibility) is active; to respond before a page renders, return a `Response` from a server middleware.
|
|
1207
1209
|
- **`getRouteRules()` from `nitro/app`**: On the server, the Nitro helper changed from `getRouteRules(event)` to `getRouteRules(method, pathname)`, which returns `{ routeRules }`.
|
|
1208
1210
|
|
|
1209
1211
|
### Removal of `experimental.externalVue`
|
|
@@ -1957,7 +1959,9 @@ export default defineNuxtConfig({
|
|
|
1957
1959
|
})
|
|
1958
1960
|
```
|
|
1959
1961
|
|
|
1960
|
-
With it on, `import { defineEventHandler, getQuery } from 'h3'`, `useRuntimeConfig(event)`, `defineNitroPlugin`, `cachedEventHandler`, `useEvent`, auto-imports from subdirectories of `server/utils
|
|
1962
|
+
With it on, `import { defineEventHandler, getQuery } from 'h3'`, `useRuntimeConfig(event)`, `defineNitroPlugin`, `cachedEventHandler`, `useEvent`, auto-imports from subdirectories of `server/utils/`, handlers registered without a `route`, and server files with a dotted suffix in their names, such as `server/middleware/auth.global.ts`, all keep working. A handler that returns a string still sends it as `text/html` unless it sets a content type, and a handler that returns `null` still responds with `204 No Content`, or with the status it set.
|
|
1963
|
+
|
|
1964
|
+
With `nitroLegacy.h3` on, Nuxt also removes any server alias that points `h3` at h3 v1, such as one a module sets so that `h3` resolves to the copy `nitropack` depends on, and reports it with `NUXT_B9015`. Nitro v3 can't run h3 v1, so with the alias removed, Nitro v2 code gets the h3 v1 helpers and other server code gets h3 v2.
|
|
1961
1965
|
|
|
1962
1966
|
Each part is a separate switch, so you can migrate one at a time:
|
|
1963
1967
|
|
|
@@ -1968,12 +1972,14 @@ export default defineNuxtConfig({
|
|
|
1968
1972
|
specifiers: true, // `nitropack`, `nitropack/runtime`, `#internal/nitro`
|
|
1969
1973
|
runtimeConfig: true, // the `useRuntimeConfig(event)` signature
|
|
1970
1974
|
imports: false, // the Nitro v2 auto-import names, and nested `server/utils/` files
|
|
1971
|
-
config: false, // Nitro v2 config shapes and removed-option warnings
|
|
1975
|
+
config: false, // Nitro v2 config shapes, dotted server file names, and removed-option warnings
|
|
1972
1976
|
},
|
|
1973
1977
|
})
|
|
1974
1978
|
```
|
|
1975
1979
|
|
|
1976
|
-
The `beforeResponse` and `
|
|
1980
|
+
The `beforeResponse`, `afterResponse`, `render:before` and `render:response` hooks need no switch. Whenever the layer is active, for your code or for a module's, Nuxt emits `beforeResponse` and `afterResponse` from the Nitro v3 `response` hook, and `render:before` and `render:response` around each page render. It reports any case it can't handle. Nitro v2 plugins that the layer covers, and `useNitroApp()` imported from `nitropack/runtime`, also get a `nitroApp.hooks.callHook()` that always returns a promise, as in Nitro v2, so `callHook('my-hook').catch(...)` keeps working.
|
|
1981
|
+
|
|
1982
|
+
On Nuxt 4 with Nitro v3, when `nitroLegacy.config` is on, error responses carry the `x-content-type-options: nosniff`, `x-frame-options: DENY` and `referrer-policy: no-referrer` headers, and JSON error responses also carry `content-security-policy: script-src 'none'; frame-ancestors 'none';`. On Nuxt 5, and on Nuxt 4 with `nitroLegacy.config` off, Nuxt doesn't add these headers to error responses.
|
|
1977
1983
|
|
|
1978
1984
|
### What the Layer Doesn't Cover
|
|
1979
1985
|
|