useCookieLocale() does not work in server context (SSR) #2975
Labels
bug 🐛
cookie
help wanted
🔨 p3-minor-bug
Priority 3: a bug in an edge case that only affects very specific usage
PR Welcome
ssr
upstream issue
Environment
Reproduction
https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-hmdag5?file=middleware%2Fssr-context-cookie.ts
Describe the bug
useCookieLocale()
always return ref with empty string in server context (SSR).This is
useCookieLocale()
source code:In server part there is a
useRequestHeaders(['cookie'])
call which always return typeNext we have this line:
It is incorrect, because,
cookie
variable is object which only has one property which iscookie
, but in this line we are trying to getcookieKey
key from it.For example in my app this code:
Prints this to console:
Additional context
Since Nuxt
useCookie()
is SSR friendly, i think thatuseCookieLocale
could be rewritten as such:Logs
No response
The text was updated successfully, but these errors were encountered: