Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix(nuxt): ignore cache rules for middleware and errors (#8291)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 18, 2022
1 parent e0d6812 commit 2b2a5f3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/nuxt/package.json
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions packages/nuxt/src/core/nitro.ts
Expand Up @@ -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: {
Expand Down
7 changes: 4 additions & 3 deletions packages/nuxt/src/core/runtime/nitro/error.ts
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/package.json
Expand Up @@ -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"
},
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2b2a5f3

Please sign in to comment.