fix(nuxt): ignore cache rules for middleware and errors (#8291)

This commit is contained in:
pooya parsa 2022-10-18 20:01:23 +02:00 committed by GitHub
parent e0d6812b66
commit 2b2a5f3f89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 11 deletions

View File

@ -58,7 +58,7 @@
"knitwork": "^0.1.2",
"magic-string": "^0.26.7",
"mlly": "^0.5.16",
"nitropack": "npm:nitropack-edge@0.6.0-27768225.ba21751",
"nitropack": "npm:nitropack-edge@0.6.0-27768582.4603279",
"nuxi": "3.0.0-rc.11",
"ohash": "^0.1.5",
"ohmyfetch": "^0.4.20",

View File

@ -37,6 +37,9 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
devHandlers: [],
baseURL: nuxt.options.app.baseURL,
virtual: {},
routeRules: {
'/__nuxt_error': { cache: false }
},
runtimeConfig: {
...nuxt.options.runtimeConfig,
nitro: {

View File

@ -20,9 +20,10 @@ export default <NitroErrorHandler> async function errorhandler (error: H3Error,
}
// Set response code and message
event.res.statusCode = errorObject.statusCode as any as number
event.res.statusMessage = errorObject.statusMessage
event.res.statusCode = (errorObject.statusCode !== 200 && errorObject.statusCode) as any as number || 500
if (errorObject.statusMessage) {
event.res.statusMessage = errorObject.statusMessage
}
// Console output
if (error.unhandled || error.fatal) {
const tags = [

View File

@ -18,7 +18,7 @@
"@types/semver": "^7",
"@vitejs/plugin-vue": "^3.1.2",
"@vueuse/head": "~1.0.0-rc.9",
"nitropack": "npm:nitropack-edge@0.6.0-27768225.ba21751",
"nitropack": "npm:nitropack-edge@0.6.0-27768582.4603279",
"unbuild": "latest",
"vite": "~3.1.8"
},

View File

@ -429,7 +429,7 @@ importers:
knitwork: ^0.1.2
magic-string: ^0.26.7
mlly: ^0.5.16
nitropack: npm:nitropack-edge@0.6.0-27768225.ba21751
nitropack: npm:nitropack-edge@0.6.0-27768582.4603279
nuxi: workspace:*
ohash: ^0.1.5
ohmyfetch: ^0.4.20
@ -473,7 +473,7 @@ importers:
knitwork: 0.1.2
magic-string: 0.26.7
mlly: 0.5.16
nitropack: /nitropack-edge/0.6.0-27768225.ba21751
nitropack: /nitropack-edge/0.6.0-27768582.4603279
nuxi: link:../nuxi
ohash: 0.1.5
ohmyfetch: 0.4.20
@ -508,7 +508,7 @@ importers:
create-require: ^1.1.1
defu: ^6.1.0
jiti: ^1.16.0
nitropack: npm:nitropack-edge@0.6.0-27768225.ba21751
nitropack: npm:nitropack-edge@0.6.0-27768582.4603279
pathe: ^0.3.9
pkg-types: ^0.3.5
postcss-import-resolver: ^2.0.0
@ -537,7 +537,7 @@ importers:
'@types/semver': 7.3.12
'@vitejs/plugin-vue': 3.1.2_vite@3.1.8
'@vueuse/head': 1.0.0-rc.9
nitropack: /nitropack-edge/0.6.0-27768225.ba21751
nitropack: /nitropack-edge/0.6.0-27768582.4603279
unbuild: 0.9.4
vite: 3.1.8
@ -6453,8 +6453,8 @@ packages:
/neo-async/2.6.2:
resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==}
/nitropack-edge/0.6.0-27768225.ba21751:
resolution: {integrity: sha512-XDXE1D4oDuiuqGy578WvWlDT9eQEVVFqaQVEygTcmJahdkW2yWHhBM94xWrvQcw7MUWNzIzF716TK4s5QK13Fw==}
/nitropack-edge/0.6.0-27768582.4603279:
resolution: {integrity: sha512-pyKJG/xE8F3g/Z7vkyvSS2dEIDAII8mp4GMcUfxxR6+PubNy2nI87udKGKqQF2DFlEIlw5VLr+DqET7+FqwMOQ==}
engines: {node: ^14.16.0 || ^16.11.0 || ^17.0.0 || ^18.0.0}
hasBin: true
dependencies: