Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useRequestHeaders and useFetch are incompatible in 3.8.0 #23900

Closed
Ingramz opened this issue Oct 23, 2023 · 2 comments · Fixed by #24333
Closed

useRequestHeaders and useFetch are incompatible in 3.8.0 #23900

Ingramz opened this issue Oct 23, 2023 · 2 comments · Fixed by #24333

Comments

@Ingramz
Copy link

Ingramz commented Oct 23, 2023

Environment


  • Operating System: Linux
  • Node Version: v18.18.0
  • Nuxt Version: 3.8.0
  • CLI Version: 3.9.1
  • Nitro Version: 2.7.0
  • Package Manager: npm@9.4.2
  • Builder: -
  • User Config: devtools
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-mgk9r8

Describe the bug

#23462 introduced headers option value as one of the hash components for useFetch requests. This however broke the example of supplying headers: useRequestHeaders() as shown in docs, because on server side and client side the supplied value are different (on client side it will always return an empty object). This results in a cache miss and triggers a re-fetch data being null on hydration.

Additional context

No response

Logs

No response

@stackblitz
Copy link

stackblitz bot commented Oct 23, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@sisou
Copy link

sisou commented Oct 25, 2023

Just hit this too and found that the opts.headers is part of the key hash, which is different between server and client when using cookie forwarding.

A workaround is to supply your own unique key in the useFetch options (or to use useAsyncData, even works without specifying the key manually as the first argument).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants