From 7a9246abeda58395f1113ff7a0a1ee751c920b7e Mon Sep 17 00:00:00 2001 From: Chengmin Date: Wed, 12 Mar 2025 23:00:28 -0400 Subject: [PATCH] Fix preview issue --- app/composables/useWpFetch.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/composables/useWpFetch.ts b/app/composables/useWpFetch.ts index b6168bb..8bf1e1a 100644 --- a/app/composables/useWpFetch.ts +++ b/app/composables/useWpFetch.ts @@ -1,22 +1,21 @@ // Fetch from WP, parse response to camelCase object and return ref export function useWpFetch(endpoint: string, options: object = {}) { const baseURL = useRuntimeConfig().public.wordpressApiUrl + const { enabled } = usePreviewMode() const response = useFetch(endpoint, { transform: (data) => { return keysToCamelCase(data || {}) }, onRequest({ options }) { - const { enabled } = usePreviewMode() - // Add credentials to fetch request if preview enabled if (enabled.value) { options.credentials = 'include' - options.headers = { ...options.headers, Preview: query.preview } } }, baseURL, - ...options + ...options, + server: !enabled.value }) return response