Route local dev hostnames that resolve to loopback to the host machine - #1
Open
ygerasimov wants to merge 1 commit into
Open
Route local dev hostnames that resolve to loopback to the host machine#1ygerasimov wants to merge 1 commit into
ygerasimov wants to merge 1 commit into
Conversation
run-worker.mjs only rewrote literal localhost/127.0.0.1-style hostnames to host.docker.internal. Local dev tooling (ddev's *.ddev.site, Lando's *.lndo.site, *.test/*.localhost setups) serves custom hostnames whose public DNS also resolves to a loopback address, but the screenshot-worker container can't reach the host through those - 127.0.0.1 inside the container is the container itself, so captures silently failed with "site can't be reached". containerReachableUrl() now does a DNS lookup for any hostname that isn't one of the known local literals, and if it resolves to a loopback address, routes it to the host via an extra `--add-host <hostname>:host-gateway` instead of rewriting the URL - keeping the original hostname intact so TLS SNI and Host-based vhost routing (as ddev's router relies on) still work.
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
run-worker.mjs'scontainerReachableUrl()only rewrote literallocalhost/127.0.0.1-style hostnames tohost.docker.internal. Local dev tooling (ddev's*.ddev.site, Lando's*.lndo.site,*.test/*.localhostsetups) serves custom hostnames whose public DNS also resolves to a loopback address — but the screenshot-worker container can't reach the host through those, since127.0.0.1inside the container is the container itself. Captures against these URLs silently failed with "this site can't be reached".--add-host <hostname>:host-gatewayon the container instead of rewriting the URL — keeping the original hostname intact so TLS SNI and Host-based vhost routing (e.g. ddev's router) still work correctly.upload-screenshot/SKILL.mdto describe the new behavior.Test plan
node --checkpasses on the modified scriptcontainerReachableUrl()againstlocalhost,127.0.0.1, a ddev hostname, and a normal remote hostname — literal-local rewrite behavior unchanged, ddev hostname now correctly routed via--add-host, remote hostname unaffectedhttps://d11.ddev.site:33001) through the worker container using the patched script — screenshots succeeded (previously failed with "site can't be reached" using the unpatched script against the same URL)🤖 Generated with Claude Code