We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
useCookie
1 parent def17ef commit ba6fb6dCopy full SHA for ba6fb6d
1 file changed
src/runtime/plugin.ts
@@ -28,9 +28,16 @@ export default defineNuxtPlugin((nuxtApp) => {
28
29
if (!token.value) {
30
if (clientConfig.tokenStorage === 'cookie') {
31
- const t = useCookie(clientConfig.tokenName!).value
32
- if (t) {
33
- token.value = t
+ if (import.meta.client) {
+ const t = useCookie(clientConfig.tokenName!).value
+ if (t) {
34
+ token.value = t
35
+ }
36
+ } else if (requestCookies?.cookie) {
37
+ const t = requestCookies.cookie.split(';').find(c => c.trim().startsWith(`${clientConfig.tokenName}=`))?.split('=')?.[1]
38
39
40
41
}
42
} else if (import.meta.client && clientConfig.tokenStorage === 'localStorage') {
43
token.value = localStorage.getItem(clientConfig.tokenName!)
0 commit comments