mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-30 21:09:53 +00:00
Adds watch on auth state that refreshes remote config. In future PR, the remote config system and feature flags should be consolidated and moved out of ComfyApi. Currently, we need feature flags before GraphView mounts, but also need to add auth headers after auth, which necessitates these parallel systems temporarily ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7197-refresh-feature-flags-on-auth-or-subscription-state-change-2c06d73d3650810a906ad36a60c86600) by [Unito](https://www.unito.io)
24 lines
665 B
TypeScript
24 lines
665 B
TypeScript
import { api } from '@/scripts/api'
|
|
|
|
import { remoteConfig } from './remoteConfig'
|
|
|
|
export async function refreshRemoteConfig(): Promise<void> {
|
|
try {
|
|
const response = await api.fetchApi('/features', { cache: 'no-store' })
|
|
if (response.ok) {
|
|
const config = await response.json()
|
|
window.__CONFIG__ = config
|
|
remoteConfig.value = config
|
|
return
|
|
}
|
|
|
|
console.warn('Failed to load remote config:', response.statusText)
|
|
if (response.status === 401 || response.status === 403) {
|
|
window.__CONFIG__ = {}
|
|
remoteConfig.value = {}
|
|
}
|
|
} catch (error) {
|
|
console.error('Failed to fetch remote config:', error)
|
|
}
|
|
}
|