[PR #21] [MERGED] fix: resolve host-relative follow-up links against the origin, not baseUrl #33

Closed
opened 2026-10-31 22:04:00 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-typescript-sdk/pull/21
Author: @sundar-svg
Created: 7/23/2026
Status: ✅ Merged
Merged: 7/24/2026
Merged by: @sundar-svg

Base: main ← Head: sundar/host-relative-follow-up-links


📝 Commits (1)

  • 684168e fix: resolve host-relative follow-up links against the origin, not baseUrl

📊 Changes

2 files changed (+89 additions, -1 deletions)

View changed files

➕ src/low/followUpLinks.test.ts (+79 -0)
📝 src/low/transport.ts (+10 -1)

📄 Description

Description

TypeScript mirror of Comfy-Org/ComfyPythonSDK#17 — the same bug existed verbatim in urlFor (src/low/transport.ts).

The serverless gateway serves the v2 contract under /deployment/{id}/api/v2 and returns job.urls.* follow-up links that are host-relative and already include that mount prefix. urlFor only recognized links starting with /api/, so a gateway self link fell into the internal-shorthand branch and was built as baseUrl + /api/v2 + link → double prefix → 404 on the first poll after submit.

Fix: a leading-slash path containing /api/ is a server-returned link and resolves against the origin — the link is authoritative about its own path. Internal shorthand paths (/jobs/…, /assets…) still resolve under baseUrl + /api/v2; Cloud / self-hosted construction is byte-identical (baseUrl == origin there); auth attachment is unaffected (same origin, existing isSameOrigin logic).

The resolution rule is being pinned in the contract itself: Comfy-Org/cloud#5498 documents it on the JobUrls schema.

How tested

  • pnpm test — 134 passed (130 existing + 4 new resolution/auth regression tests in src/low/followUpLinks.test.ts, driven through a capturing fetch so the full request path is exercised)
  • pnpm lint, pnpm typecheck clean

🤖 Generated with Claude Code

https://claude.ai/code/session_01KV7wUb2hyzKHsR52ZJTvAm


🔄 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/Comfy-Org/comfy-typescript-sdk/pull/21 **Author:** [@sundar-svg](https://github.com/sundar-svg) **Created:** 7/23/2026 **Status:** ✅ Merged **Merged:** 7/24/2026 **Merged by:** [@sundar-svg](https://github.com/sundar-svg) **Base:** `main` ← **Head:** `sundar/host-relative-follow-up-links` --- ### 📝 Commits (1) - [`684168e`](https://github.com/Comfy-Org/comfy-typescript-sdk/commit/684168ef2958782c0c7386dce90d042ba2446965) fix: resolve host-relative follow-up links against the origin, not baseUrl ### 📊 Changes **2 files changed** (+89 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `src/low/followUpLinks.test.ts` (+79 -0) 📝 `src/low/transport.ts` (+10 -1) </details> ### 📄 Description ## Description TypeScript mirror of Comfy-Org/ComfyPythonSDK#17 — the same bug existed verbatim in `urlFor` (`src/low/transport.ts`). The serverless gateway serves the v2 contract under `/deployment/{id}/api/v2` and returns `job.urls.*` follow-up links that are host-relative **and already include that mount prefix**. `urlFor` only recognized links starting with `/api/`, so a gateway self link fell into the internal-shorthand branch and was built as `baseUrl + /api/v2 + link` → double prefix → 404 on the first poll after submit. Fix: a leading-slash path containing `/api/` is a server-returned link and resolves against the **origin** — the link is authoritative about its own path. Internal shorthand paths (`/jobs/…`, `/assets…`) still resolve under `baseUrl + /api/v2`; Cloud / self-hosted construction is byte-identical (baseUrl == origin there); auth attachment is unaffected (same origin, existing `isSameOrigin` logic). The resolution rule is being pinned in the contract itself: Comfy-Org/cloud#5498 documents it on the `JobUrls` schema. ## How tested - `pnpm test` — 134 passed (130 existing + 4 new resolution/auth regression tests in `src/low/followUpLinks.test.ts`, driven through a capturing `fetch` so the full request path is exercised) - `pnpm lint`, `pnpm typecheck` clean 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KV7wUb2hyzKHsR52ZJTvAm --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 22:04:00 +00: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
Comfy-Org/comfy-typescript-sdk#33
No description provided.