fix: support relative container fetch URLs - #238
Merged
mattjohnsonpint merged 3 commits intoAug 22, 2026
Merged
Conversation
badmuriss
marked this pull request as ready for review
August 11, 2026 13:05
commit: |
Flatten the single-test describe block into the file's existing naming convention and drop the objectContaining assertion that duplicated the exact-URL check on the first argument. Add coverage for a relative URL combined with init and an explicit port, and a guard asserting absolute URLs are still passed through unchanged, which is the behavior most at risk from resolving against a base origin.
Relative paths resolve against http://container, so the container sees Host: container. Routing is unaffected, but applications that validate the Host header need to allow it or use an absolute URL.
mattjohnsonpint
force-pushed
the
agent/fix-relative-container-fetch
branch
from
August 22, 2026 00:29
3cd0706 to
679b95a
Compare
mattjohnsonpint
approved these changes
Aug 22, 2026
Contributor
|
Thanks for your contributions! I added some more tests and some info to the readme to match. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RequestinputsWhy
containerFetch('/api/data')is documented as supported, but the URL overload passed the relative path directly to theRequestconstructor. SinceRequestrequires an absolute URL when no environment origin exists, the call failed withTypeError: Failed to parse URL from /api/databefore reaching the container.The URL overload now resolves its input against
http://container. This supplies the origin required byRequestwhile the existing TCP port fetch continues to route the request to the selected container port.Fixes #28.
Testing
npm run typechecknpm run typecheck:allnpm run test:unitnpm run lintnpm run format:checknpx changeset statusI also attempted
npm run test. The local integration suite could not start its test containers and timed out in workerd withkj/timer.c++: overloaded: operation timed out, including the existing startup and HTTP fetch cases. The unit regression for this change passes.