diff --git a/composables/useApiFetch.ts b/composables/useApiFetch.ts index cad1806..fdba2b1 100644 --- a/composables/useApiFetch.ts +++ b/composables/useApiFetch.ts @@ -3,12 +3,15 @@ import { UseFetchOptions } from "nuxt/app"; const useApiFetch = async (url: string, options?: any) => { const at = useCookie("rockfic_cookie", { default: undefined }); const { token } = useAuth(); + let head = { + ...(options?.headers || {}), + }; + if (token.value) { + head.Authorization = token.value; + } return useFetch("/api" + url, { method: "get", - headers: { - ...(options?.headers || {}), - Authorization: `Bearer ${token.value}`, - }, + headers: head, ...options, }); };