Request missing headers after error-handling through error page
See original GitHub issueEnvironment
Nuxt CLI v3.0.0-rc.4 10:33:52 RootDir: 10:33:53 Nuxt project info: 10:33:53
- Operating System:
Darwin
- Node Version:
v14.19.3
- Nuxt Version:
3.0.0-rc.4
- Package Manager:
yarn@1.22.15
- Builder:
vite
- User Config:
alias
,modules
,css
,build
,vite
- Runtime Modules:
@pinia/nuxt@0.1.9
,shared-front/nuxt/axios
,shared-front/nuxt/cookies
,shared-front/nuxt/registry
,shared-front/nuxt/domain
,shared-front/nuxt/theme
,shared-front/nuxt/components
,shared-front/nuxt/mq-handler
- Build Modules:
-
Reproduction
https://stackblitz.com/edit/github-pgghw6
Describe the bug
After handling error, nitro make request to /__nuxt_error
, but this request lost all headers, and ErrorPage cannot access them
https://github.com/nuxt/framework/blob/bb8942a401cef3d41c39e9d50e6630e766998c1c/packages/nuxt/src/core/runtime/nitro/error.ts#L47
Additional context
Fixed with this code
... $fetch(withQuery('/__nuxt_error', errorObject), {
headers: event.req.headers,
}) ...
Logs
console.log from minimal-reproduce
app headers {
accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
connection: 'close',
'content-length': '0',
host: 'localhost:3000',
origin: 'https://localhost:3000',
referer: 'https://localhost:3000/',
'sec-ch-ua': '"Chromium";v="104", " Not A;Brand";v="99", "Google Chrome";v="104"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36'
}
[Vue warn]: Unhandled error during execution of setup function
at <Error onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >
[nitro] [dev] [unhandledRejection] Error: some error
at setup (/home/projects/github-pgghw6/pages/error.vue:6:7)
at _sfc_main.setup (/home/projects/github-pgghw6/pages/error.vue:28:23)
at callWithErrorHandling (/home/projects/github-pgghw6/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:157:22)
at setupStatefulComponent (/home/projects/github-pgghw6/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7107:29)
at setupComponent (/home/projects/github-pgghw6/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7062:11)
at renderComponentVNode (/home/projects/github-pgghw6/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:172:17)
at renderVNode (/home/projects/github-pgghw6/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:295:22)
at renderComponentSubTree (/home/projects/github-pgghw6/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:259:13)
at renderComponentVNode (/home/projects/github-pgghw6/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:188:16)
at renderVNode (/home/projects/github-pgghw6/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:295:22)
error headers { host: 'localhost' }
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
#7174 sounds like my issue (close it and keep this one if it is). I believe this functionality should be optional in some way unless it’s safe to pass headers to the error call 🤔 There are many cases we want to persist a user being logged in despite showing an error page it’s really weird seeing the user not logged for a brief moment.
With last RC.12 we explicitly disable cache for
/__nuxt_error
as caching was neither easy or good idea. Merging #7340 to land in next release 👍🏼 (you can try on edge channel. please mention if still not passing correctly)