mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-08 06:30:04 +00:00
[backport cloud/1.37] fix: use authenticated API for remote config polling (#8284)
Backport of #8266 to `cloud/1.37` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8284-backport-cloud-1-37-fix-use-authenticated-API-for-remote-config-polling-2f16d73d365081d2898ff4fc1af441f0) by [Unito](https://www.unito.io) Co-authored-by: Christian Byrne <cbyrne@comfy.org>
This commit is contained in:
@@ -2,9 +2,28 @@ import { api } from '@/scripts/api'
|
||||
|
||||
import { remoteConfig } from './remoteConfig'
|
||||
|
||||
export async function refreshRemoteConfig(): Promise<void> {
|
||||
interface RefreshRemoteConfigOptions {
|
||||
/**
|
||||
* Whether to use authenticated API (default: true).
|
||||
* Set to false during bootstrap before auth is initialized.
|
||||
*/
|
||||
useAuth?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads remote configuration from the backend /features endpoint
|
||||
* and updates the reactive remoteConfig ref
|
||||
*/
|
||||
export async function refreshRemoteConfig(
|
||||
options: RefreshRemoteConfigOptions = {}
|
||||
): Promise<void> {
|
||||
const { useAuth = true } = options
|
||||
|
||||
try {
|
||||
const response = await api.fetchApi('/features', { cache: 'no-store' })
|
||||
const response = useAuth
|
||||
? await api.fetchApi('/features', { cache: 'no-store' })
|
||||
: await fetch('/api/features', { cache: 'no-store' })
|
||||
|
||||
if (response.ok) {
|
||||
const config = await response.json()
|
||||
window.__CONFIG__ = config
|
||||
@@ -19,5 +38,7 @@ export async function refreshRemoteConfig(): Promise<void> {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch remote config:', error)
|
||||
window.__CONFIG__ = {}
|
||||
remoteConfig.value = {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user