[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:
Comfy Org PR Bot
2026-01-24 09:19:12 +09:00
committed by GitHub
parent 9b7f20c3bb
commit 7a5fb57aa0
5 changed files with 137 additions and 32 deletions

View File

@@ -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 = {}
}
}