Skip to content

fix: support relative container fetch URLs - #238

Open
badmuriss wants to merge 1 commit into
cloudflare:mainfrom
badmuriss:agent/fix-relative-container-fetch
Open

fix: support relative container fetch URLs#238
badmuriss wants to merge 1 commit into
cloudflare:mainfrom
badmuriss:agent/fix-relative-container-fetch

Conversation

@badmuriss

@badmuriss badmuriss commented Aug 11, 2026

Copy link
Copy Markdown

Summary

  • resolve relative URL paths against an internal container origin
  • preserve existing behavior for absolute URLs and Request inputs
  • add regression coverage for the relative path documented in the public API
  • publish the fix as a patch release

Why

containerFetch('/api/data') is documented as supported, but the URL overload passed the relative path directly to the Request constructor. Since Request requires an absolute URL when no environment origin exists, the call failed with TypeError: Failed to parse URL from /api/data before reaching the container.

The URL overload now resolves its input against http://container. This supplies the origin required by Request while the existing TCP port fetch continues to route the request to the selected container port.

Fixes #28.

Testing

  • npm run typecheck
  • npm run typecheck:all
  • npm run test:unit
  • npm run lint
  • npm run format:check
  • npx changeset status

I also attempted npm run test. The local integration suite could not start its test containers and timed out in workerd with kj/timer.c++: overloaded: operation timed out, including the existing startup and HTTP fetch cases. The unit regression for this change passes.

@badmuriss
badmuriss marked this pull request as ready for review August 11, 2026 13:05
@badmuriss
badmuriss requested a review from a team as a code owner August 11, 2026 13:05
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.

Are relative fetch paths actually supported?

1 participant