Hosted web apps can call a user's local comfy-api-proxy on 127.0.0.1 after
the user allowlists their Origin. Cross-site browser access is off by
default (DNS-rebinding / CSRF guard ported from ComfyUI core).
comfy-api-proxy \
--enable-cors-header https://app.example.com \
--token "$LOCAL_PROXY_TOKEN" # optional; recommended--enable-cors-headeris repeatable. Explicithttp(s)://host[:port]only —*is refused.- Allowlisted Origins get CORS preflight (
OPTIONS→204), may sendAuthorization/Content-Type/Idempotency-Key, and can readRetry-After,Content-Range, andAccept-Rangeson responses. GET /api/v2/healthis readable cross-origin when the Origin is allowlisted. Streaming responses (SSE) get the same CORS headers viaon_response_prepare.- Non-allowlisted Origins keep today's
403 forbidden_originbehaviour when the request is cross-site or itsOrigindisagrees with a loopbackHost. A same-origin request is unaffected — the guard exists to stop cross-site callers, not to require an allowlist entry for the proxy's own page.
The allowlist does the anti-CSRF work: attacker Origins are not listed.
--token is an extra local lock (useful when widening --host); for a
loopback-only single-user setup it is not a Cloud-grade secret.
@comfyorg/sdk is Node-only for v1 (browser support is out of scope).
Call /api/v2/* with fetch against the proxy base URL. A browser SDK build
is a follow-up, not required to use this path.
const r = await fetch("http://127.0.0.1:8189/api/v2/health", {
headers: { Authorization: `Bearer ${token}` }, // omit if no --token
});