Skip to content

feat: allow --comfy-api-base target ephemeral testenvs#14569

Open
bigcat88 wants to merge 1 commit into
masterfrom
feat/ephemeral-env-features
Open

feat: allow --comfy-api-base target ephemeral testenvs#14569
bigcat88 wants to merge 1 commit into
masterfrom
feat/ephemeral-env-features

Conversation

@bigcat88

@bigcat88 bigcat88 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Today the frontend only learns which backend to talk to at build time. This PR allows Frontend to read the comfy-api-base at runtime instead.

Supersedes: #14200

When you start ComfyUI with --comfy-api-base pointed at one of our non-production backends (staging, or a per-PR preview environment under *.testenvs.comfy.org), the server now includes that backend's URLs in its /features response.
The frontend reads them from there, so the same prebuilt UI can follow along without anyone rebuilding it.

Preview environments keep their friendly URL separate from the actual API host, so you can pass the friendly one (pr-N.testenvs.comfy.org) and let the server resolve the real host (pr-N-registry.testenvs.comfy.org) for you, both in what it tells the frontend and in where the API nodes send their calls.

Production and ordinary self-hosting are untouched: the server only adds this when you point it somewhere non-production, so everyone else sees exactly what they do today.

API Node PR Checklist

Scope

  • Is API Node Change

Pricing & Billing

  • Need pricing update
  • No pricing update

If Need pricing update:

  • Metronome rate cards updated
  • Auto‑billing tests updated and passing

QA

  • QA done
  • QA not required

Comms

  • Informed Kosinkadink

Signed-off-by: bigcat88 <bigcat88@icloud.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

A new module comfy/comfy_api_env.py is added to detect staging and testenv API hosts, normalize testenv main-host URLs to their -registry sibling form, and produce a frontend config dict with overridden comfy_api_base_url and comfy_platform_base_url for staging-tier bases (returning None for production). get_server_features() in comfy_api/feature_flags.py now merges the output of get_frontend_config() into the returned feature flags dict. default_base_url() in comfy_api_nodes/util/_helpers.py wraps the configured base URL with normalize_comfy_api_base(). Tests covering all three behaviors are added to tests-unit/feature_flags_test.py.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: enabling runtime targeting of ephemeral testenvs via the --comfy-api-base flag, which is the core feature this PR introduces.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description clearly explains the PR's purpose: enabling runtime backend API discovery for the frontend via the /features response, handling environment-specific URL normalization.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@comfy/comfy_api_env.py`:
- Around line 23-32: The normalize_comfy_api_base function only preserves the
scheme and hostname when rewriting the URL on line 32, but discards the original
URL's port, path, query parameters, and fragment. This can silently retarget
requests when the input includes a custom port or path prefix. To fix this,
preserve all URL components from the parsed object when reconstructing the URL:
either manually include parsed.port, parsed.path, parsed.query, and
parsed.fragment in the f-string, or use urlunparse to reconstruct the full URL
after modifying the hostname in the parsed URL object.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ea0505eb-c654-45cc-a238-d54ae12d0c0a

📥 Commits

Reviewing files that changed from the base of the PR and between dc3f8f3 and 7ed56ac.

📒 Files selected for processing (4)
  • comfy/comfy_api_env.py
  • comfy_api/feature_flags.py
  • comfy_api_nodes/util/_helpers.py
  • tests-unit/feature_flags_test.py

Comment thread comfy/comfy_api_env.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant