Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

fix: preserve shared API helper type inference

HoshinoSuzumiBotd558158f7c0a
diff --git a/packages/console/app/composables/useConsoleApi.ts b/packages/console/app/composables/useConsoleApi.ts
index ec26e2ee..0d6069ec 100644
--- a/packages/console/app/composables/useConsoleApi.ts
+++ b/packages/console/app/composables/useConsoleApi.ts
@@ -1,18 +1,26 @@
-/** Entry-owned base for application APIs; storage upload URLs bypass this adapter. */
+/** Apply the entry API base using request-scoped fetch, preserving SSR cookies. */
export function useConsoleApi() {
const baseURL = useRuntimeConfig().public.console.apiBase
- const fetcher = useRequestFetch()
- return ((
- request: Parameters<typeof fetcher>[0],
- options?: Parameters<typeof fetcher>[1],
- ) => fetcher(request, { baseURL, ...options })) as typeof fetcher
+ // Keep the implementation boundary independent of Nuxt's recursive route types.
+ // Callers retain the same generic response inference as the original $fetch.
+ const fetcher = useRequestFetch() as (
+ request: unknown,
+ options?: Record<string, unknown>,
+ ) => Promise<unknown>
+ return ((request: unknown, options?: Record<string, unknown>) =>
+ fetcher(request, { baseURL, ...options })) as typeof $fetch
}
-/** Preserve Nuxt useFetch inference while applying the entry-owned API base. */
+/** Preserve useFetch inference without instantiating its generic overloads here. */
export const useConsoleFetch = ((
- request: Parameters<typeof useFetch>[0],
- options?: Parameters<typeof useFetch>[1],
-) =>
- useFetch(request, {
+ request: unknown,
+ options?: Record<string, unknown>,
+) => {
+ const fetcher = useFetch as (
+ request: unknown,
+ options?: Record<string, unknown>,
+ ) => unknown
+ return fetcher(request, {
baseURL: useRuntimeConfig().public.console.apiBase,
...options,
- })) as typeof useFetch
+ })
+}) as typeof useFetch
diff --git a/packages/gallery/app/composables/useGalleryApi.ts b/packages/gallery/app/composables/useGalleryApi.ts
index 2b229292..b7342c6c 100644
--- a/packages/gallery/app/composables/useGalleryApi.ts
+++ b/packages/gallery/app/composables/useGalleryApi.ts
@@ -1,17 +1,26 @@
-/** Public gallery API base is supplied by the consuming entry. */
+/** Apply the entry API base using request-scoped fetch, preserving SSR cookies. */
export function useGalleryApi() {
- const fetcher = useRequestFetch()
const baseURL = useRuntimeConfig().public.gallery.apiBase
- return ((
- request: Parameters<typeof fetcher>[0],
- options?: Parameters<typeof fetcher>[1],
- ) => fetcher(request, { baseURL, ...options })) as typeof fetcher
+ // Keep the implementation boundary independent of Nuxt's recursive route types.
+ // Callers retain the same generic response inference as the original $fetch.
+ const fetcher = useRequestFetch() as (
+ request: unknown,
+ options?: Record<string, unknown>,
+ ) => Promise<unknown>
+ return ((request: unknown, options?: Record<string, unknown>) =>
+ fetcher(request, { baseURL, ...options })) as typeof $fetch
}
+/** Preserve useFetch inference without instantiating its generic overloads here. */
export const useGalleryFetch = ((
- request: Parameters<typeof useFetch>[0],
- options?: Parameters<typeof useFetch>[1],
-) =>
- useFetch(request, {
+ request: unknown,
+ options?: Record<string, unknown>,
+) => {
+ const fetcher = useFetch as (
+ request: unknown,
+ options?: Record<string, unknown>,
+ ) => unknown
+ return fetcher(request, {
baseURL: useRuntimeConfig().public.gallery.apiBase,
...options,
- })) as typeof useFetch
+ })
+}) as typeof useFetch