From 2ce68c8a58d035bbc658d4e3333c50dd6808ae92 Mon Sep 17 00:00:00 2001 From: Hunter Senft-Grupp Date: Sun, 31 May 2026 13:38:20 -0400 Subject: [PATCH] refactor: use axios interceptor instead of watcher for runtime base URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reading the base URL at axios.create() time captures whatever remoteConfig holds at module-load — which on OSS is the empty default, because static imports are hoisted above main.ts's top-level 'await refreshRemoteConfig()'. A subsequent 'watch' never fires because the value is already correct by the time the watcher is established. A request-time interceptor reads the current URL on every call, which is both simpler and actually correct. --- src/services/comfyRegistryService.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/services/comfyRegistryService.ts b/src/services/comfyRegistryService.ts index f19263d96b..46eeaa7386 100644 --- a/src/services/comfyRegistryService.ts +++ b/src/services/comfyRegistryService.ts @@ -1,13 +1,12 @@ import type { AxiosError, AxiosResponse } from 'axios' import axios from 'axios' -import { ref, watch } from 'vue' +import { ref } from 'vue' import { getComfyApiBaseUrl } from '@/config/comfyApi' import type { components, operations } from '@/types/comfyRegistryTypes' import { isAbortError } from '@/utils/typeGuardUtil' const registryApiClient = axios.create({ - baseURL: getComfyApiBaseUrl(), headers: { 'Content-Type': 'application/json' }, @@ -17,6 +16,14 @@ const registryApiClient = axios.create({ } }) +// Resolve the base URL per request so server-provided overrides applied +// after this module is first imported (e.g. via remoteConfig) take effect +// on the next call, without temporal coupling to module-load order. +registryApiClient.interceptors.request.use((config) => { + config.baseURL = getComfyApiBaseUrl() + return config +}) + /** * Service for interacting with the Comfy Registry API */ @@ -24,13 +31,6 @@ export const useComfyRegistryService = () => { const isLoading = ref(false) const error = ref(null) - watch( - () => getComfyApiBaseUrl(), - (url) => { - registryApiClient.defaults.baseURL = url - } - ) - const handleApiError = ( err: unknown, context: string,