[PR #8844] [MERGED] feat(media): custom headers and API-key auth for local ComfyUI/SwarmUI/A1111 requests #8839

Closed
opened 2026-11-07 17:40:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8844
Author: @bakatrouble
Created: 11/4/2026
Status: ✅ Merged
Merged: 11/7/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/comfyui-custom-headers


📝 Commits (10+)

  • a57e92b feat(media): custom headers and API-key auth for local ComfyUI/SwarmUI/A1111 requests
  • 355c6f9 Merge branch 'staging' into feat/comfyui-custom-headers
  • ad8f6e8 Merge upstream staging into feat/comfyui-custom-headers
  • ceb8aa4 Merge fork branch (maintainer staging sync) into feat/comfyui-custom-headers
  • fc0333c Merge pull request #8878 from Pasta-Devs/staging
  • eae4ec0 Merge branch 'Pasta-Devs:main' into feat/comfyui-custom-headers
  • 60befa7 fix(media): send API-key auth and custom headers on local-backend discovery
  • 6d0fbb7 Merge fork branch (main sync) into feat/comfyui-custom-headers
  • a7ac91d Merge branch 'staging' into feat/comfyui-custom-headers
  • 8bb5da5 fix(media): resolve discovery headers without service inference

📊 Changes

21 files changed (+816 additions, -82 deletions)

View changed files

📝 docs/media/comfyui.md (+13 -1)
📝 packages/client/src/components/connections/ConnectionEditor.tsx (+23 -0)
📝 packages/server/src/routes/connections.routes.ts (+109 -25)
📝 packages/server/src/routes/game.routes.ts (+3 -0)
📝 packages/server/src/routes/sprites.routes.ts (+2 -0)
📝 packages/server/src/services/capability-packages/capability-gallery-animation.service.ts (+1 -0)
📝 packages/server/src/services/generation/media-connection-fallback.ts (+1 -0)
📝 packages/server/src/services/image/image-generation.ts (+121 -35)
📝 packages/server/src/services/video/chat-video-generation.ts (+1 -0)
📝 packages/server/src/services/video/game-video-runtime.ts (+3 -0)
📝 packages/server/src/services/video/video-generation.ts (+64 -21)
📝 packages/shared/src/constants/image-generation-defaults.ts (+4 -0)
📝 packages/shared/src/constants/video-generation-defaults.ts (+3 -0)
📝 packages/shared/src/schemas/prompt.schema.ts (+10 -0)
📝 packages/shared/src/types/generation-integration.ts (+7 -0)
📝 packages/shared/src/types/image-generation-defaults.ts (+5 -0)
📝 packages/shared/src/types/video-generation-defaults.ts (+5 -0)
📝 scripts/regressions/capability-gallery-animation.regression.ts (+2 -0)
➕ scripts/regressions/local-backend-discovery-headers.regression.ts (+168 -0)
➕ scripts/regressions/local-comfyui-headers.regression.ts (+136 -0)

...and 1 more files

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #8853.

cc @SpicyMarinara — assigning the PR failed (this account lacks permission), mentioning instead per the repo agent rules.

Why this change

  • ComfyUI (and SwarmUI / AUTOMATIC1111) behind an authenticating or routing proxy — Caddy basic-auth, Cloudflare Access, ngrok-style headers — answers 401/403 with no way to add headers, and the connection's API key field was silently ignored on these local backends.

What changed

  • Local ComfyUI, SwarmUI, and AUTOMATIC1111/Forge/Draw Things image and video connections now send the connection's API key as an Authorization header: a bare token goes as Bearer, a value that already carries a scheme (such as Basic ...) is sent as-is. Previously the key was accepted by the editor but never sent to these backends.
  • New Custom Request Headers JSON object under Local image defaults and Video defaults (local backends only; hidden for RunPod/Arli/cloud) for non-secret headers. Validation reuses the existing header rules, so authentication, transport, and secret names are rejected and fail closed to sending nothing. Secrets belong in API key, which stays encrypted at rest and out of connection exports.
  • Docs: docs/media/comfyui.md gains a "Use an authenticated proxy" section and a 401/403 troubleshooting row. docs-i18n packs are not yet updated (see below).
  • Regression: scripts/regressions/local-comfyui-headers.regression.ts proves reserved header names are dropped while valid headers and Bearer auth land on reference upload, queue, history, and download requests.
  • Add-models listing, connection testing, and the SwarmUI session handshake for local backends now send the same auth/custom headers (previously headerless, so an authenticated proxy answered with an HTML page and the dialog showed Unexpected token '<', "<!DOCTYPE "...). ComfyUI object_info answers that are not JSON now read as missing metadata instead of throwing a SyntaxError.
  • Regression: scripts/regressions/local-backend-discovery-headers.regression.ts proves the discovery path against stub backends, including the 401 and HTML-login-page cases.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Commands run (all green, unattended):

  • pnpm check — exit 0 (impeccable, localization, prettier, lint, typechecks, full build)
  • node ./scripts/run-regressions.mjs --filter local-comfyui-headers — 1/1 passed
  • node ./scripts/run-regressions.mjs --filter swarmui — 3/3 passed
  • node ./scripts/run-regressions.mjs --filter image-custom-parameters — 1/1 passed
  • node ./scripts/run-regressions.mjs --filter image-generation-timeout — 1/1 passed
  • pnpm smoke:ui — 7/7 passed (desktop Chromium)

Manual verification notes

  • Reporter-verified in a real browser: created a ComfyUI image connection against a basic-auth-protected server, entered the proxy credential in API key, ran Test image — generation succeeded, confirming the key is sent as an Authorization header.
  • Reporter-verified in the same setup: the Add-models dialog now lists models instead of failing with Unexpected token '<', "<!DOCTYPE "....
  • Server-side e2e on the deployed build (htpc, GPU ComfyUI): temp connection with API key + custom header → Test image success, model listing returned 29 models, temp connection deleted.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Notes: docs/media/comfyui.md is updated in this PR. The docs-i18n packs are not — a [docs-i18n] docs/media/comfyui.md follow-up issue still needs opening (or translation before merge). No CHANGELOG.md edits (release PRs only). No version bump.

UI evidence (if applicable)

Untitled Untitled2 Untitled3 Untitled4 Untitled5 Untitled6

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8844 **Author:** [@bakatrouble](https://github.com/bakatrouble) **Created:** 11/4/2026 **Status:** ✅ Merged **Merged:** 11/7/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/comfyui-custom-headers` --- ### 📝 Commits (10+) - [`a57e92b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a57e92bb77dba90cd5a87230a264303fabec8253) feat(media): custom headers and API-key auth for local ComfyUI/SwarmUI/A1111 requests - [`355c6f9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/355c6f968bb13df13a9908a4dc3c154c0fa3d0c1) Merge branch 'staging' into feat/comfyui-custom-headers - [`ad8f6e8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ad8f6e8d64170499999f233125f4f28a350d404f) Merge upstream staging into feat/comfyui-custom-headers - [`ceb8aa4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ceb8aa46b3c4e43787b290d6fc076ea4e330c4dc) Merge fork branch (maintainer staging sync) into feat/comfyui-custom-headers - [`fc0333c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fc0333c3fe978cda5e0b919bd6faec985901704e) Merge pull request #8878 from Pasta-Devs/staging - [`eae4ec0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/eae4ec0e2af61f65045df9d8a0d3efb5ac2c7a6c) Merge branch 'Pasta-Devs:main' into feat/comfyui-custom-headers - [`60befa7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/60befa7d3f7289a648973edf3bedf222d408eda5) fix(media): send API-key auth and custom headers on local-backend discovery - [`6d0fbb7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6d0fbb7edafb09b3022a3b6867d24605bb94f0f3) Merge fork branch (main sync) into feat/comfyui-custom-headers - [`a7ac91d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a7ac91d9ea85f16aae5b2eae003238119708c34a) Merge branch 'staging' into feat/comfyui-custom-headers - [`8bb5da5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8bb5da5a46a00b505aa8ec437efa75f4905c6660) fix(media): resolve discovery headers without service inference ### 📊 Changes **21 files changed** (+816 additions, -82 deletions) <details> <summary>View changed files</summary> 📝 `docs/media/comfyui.md` (+13 -1) 📝 `packages/client/src/components/connections/ConnectionEditor.tsx` (+23 -0) 📝 `packages/server/src/routes/connections.routes.ts` (+109 -25) 📝 `packages/server/src/routes/game.routes.ts` (+3 -0) 📝 `packages/server/src/routes/sprites.routes.ts` (+2 -0) 📝 `packages/server/src/services/capability-packages/capability-gallery-animation.service.ts` (+1 -0) 📝 `packages/server/src/services/generation/media-connection-fallback.ts` (+1 -0) 📝 `packages/server/src/services/image/image-generation.ts` (+121 -35) 📝 `packages/server/src/services/video/chat-video-generation.ts` (+1 -0) 📝 `packages/server/src/services/video/game-video-runtime.ts` (+3 -0) 📝 `packages/server/src/services/video/video-generation.ts` (+64 -21) 📝 `packages/shared/src/constants/image-generation-defaults.ts` (+4 -0) 📝 `packages/shared/src/constants/video-generation-defaults.ts` (+3 -0) 📝 `packages/shared/src/schemas/prompt.schema.ts` (+10 -0) 📝 `packages/shared/src/types/generation-integration.ts` (+7 -0) 📝 `packages/shared/src/types/image-generation-defaults.ts` (+5 -0) 📝 `packages/shared/src/types/video-generation-defaults.ts` (+5 -0) 📝 `scripts/regressions/capability-gallery-animation.regression.ts` (+2 -0) ➕ `scripts/regressions/local-backend-discovery-headers.regression.ts` (+168 -0) ➕ `scripts/regressions/local-comfyui-headers.regression.ts` (+136 -0) _...and 1 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #8853. cc @SpicyMarinara — assigning the PR failed (this account lacks permission), mentioning instead per the repo agent rules. ## Why this change - ComfyUI (and SwarmUI / AUTOMATIC1111) behind an authenticating or routing proxy — Caddy basic-auth, Cloudflare Access, ngrok-style headers — answers 401/403 with no way to add headers, and the connection's API key field was silently ignored on these local backends. ## What changed - Local ComfyUI, SwarmUI, and AUTOMATIC1111/Forge/Draw Things image and video connections now send the connection's API key as an `Authorization` header: a bare token goes as `Bearer`, a value that already carries a scheme (such as `Basic ...`) is sent as-is. Previously the key was accepted by the editor but never sent to these backends. - New **Custom Request Headers** JSON object under **Local image defaults** and **Video defaults** (local backends only; hidden for RunPod/Arli/cloud) for non-secret headers. Validation reuses the existing header rules, so authentication, transport, and secret names are rejected and fail closed to sending nothing. Secrets belong in **API key**, which stays encrypted at rest and out of connection exports. - Docs: `docs/media/comfyui.md` gains a "Use an authenticated proxy" section and a 401/403 troubleshooting row. `docs-i18n` packs are not yet updated (see below). - Regression: `scripts/regressions/local-comfyui-headers.regression.ts` proves reserved header names are dropped while valid headers and `Bearer` auth land on reference upload, queue, history, and download requests. - Add-models listing, connection testing, and the SwarmUI session handshake for local backends now send the same auth/custom headers (previously headerless, so an authenticated proxy answered with an HTML page and the dialog showed `Unexpected token '<', "<!DOCTYPE "...`). ComfyUI `object_info` answers that are not JSON now read as missing metadata instead of throwing a SyntaxError. - Regression: `scripts/regressions/local-backend-discovery-headers.regression.ts` proves the discovery path against stub backends, including the 401 and HTML-login-page cases. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` Commands run (all green, unattended): - `pnpm check` — exit 0 (impeccable, localization, prettier, lint, typechecks, full build) - `node ./scripts/run-regressions.mjs --filter local-comfyui-headers` — 1/1 passed - `node ./scripts/run-regressions.mjs --filter swarmui` — 3/3 passed - `node ./scripts/run-regressions.mjs --filter image-custom-parameters` — 1/1 passed - `node ./scripts/run-regressions.mjs --filter image-generation-timeout` — 1/1 passed - `pnpm smoke:ui` — 7/7 passed (desktop Chromium) ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Reporter-verified in a real browser: created a ComfyUI image connection against a basic-auth-protected server, entered the proxy credential in **API key**, ran **Test image** — generation succeeded, confirming the key is sent as an `Authorization` header. - Reporter-verified in the same setup: the Add-models dialog now lists models instead of failing with `Unexpected token '<', "<!DOCTYPE "...`. - Server-side e2e on the deployed build (htpc, GPU ComfyUI): temp connection with API key + custom header → Test image success, model listing returned 29 models, temp connection deleted. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README) as needed - [x] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Notes: `docs/media/comfyui.md` is updated in this PR. The `docs-i18n` packs are not — a `[docs-i18n] docs/media/comfyui.md` follow-up issue still needs opening (or translation before merge). No `CHANGELOG.md` edits (release PRs only). No version bump. ## UI evidence (if applicable) <img width="2000" height="1204" alt="Untitled" src="https://github.com/user-attachments/assets/70ab6536-4eb8-43cf-a57c-98fe91f111f3" /> <img width="2000" height="1204" alt="Untitled2" src="https://github.com/user-attachments/assets/b82cb86f-042f-4757-be46-99c45d9e2c12" /> <img width="1165" height="600" alt="Untitled3" src="https://github.com/user-attachments/assets/43ce4ccc-ff77-4653-aa98-7ca8b584323a" /> <img width="1165" height="600" alt="Untitled4" src="https://github.com/user-attachments/assets/ea1c2f7d-6078-41cc-bb2f-53498db5b6cd" /> <img width="1542" height="601" alt="Untitled5" src="https://github.com/user-attachments/assets/fd8a24c8-1883-43d6-aefb-b26286a69f94" /> <img width="1542" height="601" alt="Untitled6" src="https://github.com/user-attachments/assets/ca7634bf-c41d-465a-8c82-1bf54369401f" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:40:06 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8839
No description provided.