From 1e67434a8f0d81f8a66879370c25a1946db93cc4 Mon Sep 17 00:00:00 2001 From: Mahdi Boomeri Date: Wed, 31 Aug 2022 19:13:29 +0430 Subject: [PATCH] fix: useClientHeaders returning an empty object --- src/runtime/client.ts | 3 +-- src/runtime/plugin.ts | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/runtime/client.ts b/src/runtime/client.ts index 38348a9..c7b179f 100644 --- a/src/runtime/client.ts +++ b/src/runtime/client.ts @@ -9,7 +9,6 @@ import type { ProcedureRecord, inferHandlerInput, inferProcedureInput, inferProc import type { TRPCClient, TRPCClientErrorLike } from '@trpc/client' import { objectHash } from 'ohash' import type { Ref } from 'vue' -import { useStorage } from '@vueuse/core' import { useAsyncData, useNuxtApp, useState } from '#app' import type { router } from '~/server/trpc' @@ -79,5 +78,5 @@ export function useClient(): TRPCClient { } export function useClientHeaders(initialValue: MaybeRef> = {}): Ref> { - return useStorage('trpc-nuxt-header', initialValue) + return useState('trpc-nuxt-header', () => initialValue) } diff --git a/src/runtime/plugin.ts b/src/runtime/plugin.ts index 423510c..04d43c5 100644 --- a/src/runtime/plugin.ts +++ b/src/runtime/plugin.ts @@ -13,13 +13,10 @@ export default defineNuxtPlugin((nuxtApp) => { const client = trpc.createTRPCClient({ url: `${config.baseURL}${config.endpoint}`, headers: () => { - if (nuxtApp.ssrContext) { - return { - ...unref(otherHeaders), - ...headers, - } + return { + ...unref(otherHeaders), + ...headers, } - return {} }, })