Repository navigation
Description
Found on squirrel v0.0.138 and still present on current main (read at apps/cli/src/utils/reachability.ts).
Problem
A start URL whose host answers with a redirect to a sibling subdomain (not a subdomain of the start host) makes squirrel audit --offline exit 1 before any crawling:
squirrel audit https://apps.example.com/tool/ -C surface --max-pages 30 -f json -o out.json --offline --passive
Cannot reach https://apps.example.com/tool/: refused: host outside the allowed set
with the server answering 308 Location: https://tool.example.com/. The same happens for a link-shortener style host (https://go.example.com/x) that redirects to the product domain (https://www.example.org/).
Per the docs (docs/cli/audit.mdx, "Fully offline audit") an offline audit does not follow a redirect to another site: "A page that redirects to another host is recorded as the redirect it answered with, and the other host is not requested." So not following is by design. What is wrong is how the start URL case ends.
Why it looks like a bug, not just a policy
reachability.ts has a deliberate branch for this (#819/#1418): an EGRESS_OFF_SITE_REFUSAL is mapped to { reachable: true, statusCode: 302 } so the crawl can record the redirect and the report can say "Seed redirected off-site to ..., not followed". A localhost repro (start http://localhost:PORT/tool/ redirecting to http://127.0.0.1:PORT/) takes the first, localhost-only branch and works. The non-localhost branch runs the probe through Effect.runPromise(requestOnceScoped(...)) and then tests error instanceof RequestError. Effect.runPromise rejects with a FiberFailure wrapper, not the RequestError itself, so that check appears to never match and the error falls through to the generic reachable: false, error: err.message, which is the raw "refused: host outside the allowed set" text seen above. Please confirm with a test that drives the non-localhost branch with a redirecting stub.
Expected
- Under
--offline, a start URL that redirects off the site is reported as reachable, the crawl records the redirect, and the console/JSON report carries the existing "Seed redirected off-site ..., not followed" note with the final URL. - Whatever the policy, the error (if it stays an error) names the final URL and how to audit it, for example "https://apps.example.com/tool/ redirects to https://tool.example.com/, which is outside the allowed set under --offline. Audit https://tool.example.com/ directly, or add tool.example.com to [project] domains."
Acceptance Criteria
-
squirrel audit <start> --offlinewhere<start>answers308to a different registrable or sibling host does not printCannot reach ...: refused: host outside the allowed set. - The audit either completes with the off-site seed redirect disclosed (final URL named) or exits non-zero with a message that names the final URL and the next step.
- A unit test exercises the non-localhost reachability branch with a stub that raises the off-site refusal and asserts the
reachable: true/ redirect result. - A link-shortener style start URL redirecting to another domain behaves the same way.
Activity
WilliamK112 commentedon Oct 28, 2026
I'd like to take this. I'll keep the fix focused on preserving the typed RequestError across the Effect boundary and add coverage for the non-localhost offline redirect path.
fix(cli): preserve offline seed redirects (squirrelscan#1240)