[feat] Integrate header registry with all HTTP clients

- Replace direct fetch() with fetchWithHeaders across entire codebase
- Replace axios.create() with createAxiosWithHeaders in all services
- Update tests to properly mock network client adapters
- Fix hoisting issues in test mocks for axios instances
- Ensure all network calls now support header injection

This completes Step 2: integrating the header registry infrastructure with all existing HTTP clients in the codebase.
This commit is contained in:
bymyself
2025-08-16 14:13:21 -07:00
parent d6695ea66e
commit d05153a0dc
19 changed files with 192 additions and 89 deletions

View File

@@ -2,6 +2,7 @@ import axios, { AxiosError, AxiosResponse } from 'axios'
import { ref } from 'vue'
import { api } from '@/scripts/api'
import { createAxiosWithHeaders } from '@/services/networkClientAdapter'
import {
type InstallPackParams,
type InstalledPacksResponse,
@@ -35,7 +36,7 @@ enum ManagerRoute {
REBOOT = 'manager/reboot'
}
const managerApiClient = axios.create({
const managerApiClient = createAxiosWithHeaders({
baseURL: api.apiURL(''),
headers: {
'Content-Type': 'application/json'

View File

@@ -1,12 +1,13 @@
import axios, { AxiosError, AxiosResponse } from 'axios'
import { ref } from 'vue'
import { createAxiosWithHeaders } from '@/services/networkClientAdapter'
import type { components, operations } from '@/types/comfyRegistryTypes'
import { isAbortError } from '@/utils/typeGuardUtil'
const API_BASE_URL = 'https://api.comfy.org'
const registryApiClient = axios.create({
const registryApiClient = createAxiosWithHeaders({
baseURL: API_BASE_URL,
headers: {
'Content-Type': 'application/json'

View File

@@ -3,6 +3,7 @@ import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { COMFY_API_BASE_URL } from '@/config/comfyApi'
import { createAxiosWithHeaders } from '@/services/networkClientAdapter'
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
import { type components, operations } from '@/types/comfyRegistryTypes'
import { isAbortError } from '@/utils/typeGuardUtil'
@@ -22,7 +23,7 @@ type CustomerEventsResponseQuery =
export type AuditLog = components['schemas']['AuditLog']
const customerApiClient = axios.create({
const customerApiClient = createAxiosWithHeaders({
baseURL: COMFY_API_BASE_URL,
headers: {
'Content-Type': 'application/json'

View File

@@ -1,4 +1,5 @@
import { api } from '@/scripts/api'
import { fetchWithHeaders } from '@/services/networkClientAdapter'
import type { ComfyNodeDefImpl } from '@/stores/nodeDefStore'
import { NodeSourceType, getNodeSource } from '@/types/nodeSource'
import { extractCustomNodeName } from '@/utils/nodeHelpUtil'
@@ -25,12 +26,12 @@ export class NodeHelpService {
// Try locale-specific path first
const localePath = `/extensions/${customNodeName}/docs/${node.name}/${locale}.md`
let res = await fetch(api.fileURL(localePath))
let res = await fetchWithHeaders(api.fileURL(localePath))
if (!res.ok) {
// Fall back to non-locale path
const fallbackPath = `/extensions/${customNodeName}/docs/${node.name}.md`
res = await fetch(api.fileURL(fallbackPath))
res = await fetchWithHeaders(api.fileURL(fallbackPath))
}
if (!res.ok) {
@@ -45,7 +46,7 @@ export class NodeHelpService {
locale: string
): Promise<string> {
const mdUrl = `/docs/${node.name}/${locale}.md`
const res = await fetch(api.fileURL(mdUrl))
const res = await fetchWithHeaders(api.fileURL(mdUrl))
if (!res.ok) {
throw new Error(res.statusText)

View File

@@ -2,10 +2,11 @@ import axios, { AxiosError, AxiosResponse } from 'axios'
import { ref } from 'vue'
import { COMFY_API_BASE_URL } from '@/config/comfyApi'
import { createAxiosWithHeaders } from '@/services/networkClientAdapter'
import type { components, operations } from '@/types/comfyRegistryTypes'
import { isAbortError } from '@/utils/typeGuardUtil'
const releaseApiClient = axios.create({
const releaseApiClient = createAxiosWithHeaders({
baseURL: COMFY_API_BASE_URL,
headers: {
'Content-Type': 'application/json'