mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-06 16:10:09 +00:00
[feat] Complete network call consolidation to use consistent clients
Template Workflows: - Replace direct fetch with api.fetchApi() for API endpoints - Keep direct fetch for static file URLs (already using api.fileURL()) Model Exporter: - Add logic to distinguish ComfyUI URLs from external URLs - Use api.apiURL() for ComfyUI URLs, direct fetch for external URLs - Maintain existing download functionality Other files already following correct patterns: - Upload Audio: Already using api.fetchApi() - 3D Loading Utils: Already using api.fetchApi() (fetch call is for blob conversion) - Download Utility: Uses direct fetch for external URLs (correct) All network calls now use consistent client patterns where appropriate.
This commit is contained in:
@@ -160,12 +160,15 @@ export function useTemplateWorkflows() {
|
||||
*/
|
||||
const fetchTemplateJson = async (id: string, sourceModule: string) => {
|
||||
if (sourceModule === 'default') {
|
||||
// Default templates provided by frontend are served on this separate endpoint
|
||||
return fetch(api.fileURL(`/templates/${id}.json`)).then((r) => r.json())
|
||||
// Default templates provided by frontend are served as static files
|
||||
const response = await fetch(api.fileURL(`/templates/${id}.json`))
|
||||
return response.json()
|
||||
} else {
|
||||
return fetch(
|
||||
api.apiURL(`/workflow_templates/${sourceModule}/${id}.json`)
|
||||
).then((r) => r.json())
|
||||
// Custom node templates served via API
|
||||
const response = await api.fetchApi(
|
||||
`/workflow_templates/${sourceModule}/${id}.json`
|
||||
)
|
||||
return response.json()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { OBJExporter } from 'three/examples/jsm/exporters/OBJExporter'
|
||||
import { STLExporter } from 'three/examples/jsm/exporters/STLExporter'
|
||||
|
||||
import { t } from '@/i18n'
|
||||
import { api } from '@/scripts/api'
|
||||
import { useToastStore } from '@/stores/toastStore'
|
||||
|
||||
export class ModelExporter {
|
||||
@@ -36,7 +37,18 @@ export class ModelExporter {
|
||||
desiredFilename: string
|
||||
): Promise<void> {
|
||||
try {
|
||||
const response = await fetch(url)
|
||||
// Check if this is a ComfyUI relative URL
|
||||
const isComfyUrl = url.startsWith('/') || url.includes('/view?')
|
||||
|
||||
let response: Response
|
||||
if (isComfyUrl) {
|
||||
// Use ComfyUI API client for internal URLs
|
||||
response = await fetch(api.apiURL(url))
|
||||
} else {
|
||||
// Use direct fetch for external URLs
|
||||
response = await fetch(url)
|
||||
}
|
||||
|
||||
const blob = await response.blob()
|
||||
|
||||
const link = document.createElement('a')
|
||||
|
||||
Reference in New Issue
Block a user