Use canonical API host and reject credentialed redirects

Merged
SI
5d ago
+203-9

Result

GET and POST now reject redirects before sending a second request, protecting x-api-key and POST bodies from forwarding. The default is https://api.recoupable.dev; RECOUP_API_URL still selects the initial trusted endpoint. Existing PR23 and its broader parity changes are untouched. Open PR33 (6b5f4586) separately refactors both verbs into a shared request helper that omits redirect rejection. It is not a prerequisite: future composition must keep non-following redirect handling and explicit 3xx rejection in that helper and retain the native-fetch regression tests. Neither existing PR was modified.

Validation

Local native-fetch tests reproduced 20 redirect failures plus the old-default failure before implementation. All 301/302/303/307/308 GET/POST redirects, both same-origin and cross-origin, now reject with zero destination requests. Direct query/body/key behavior remains intact. Fake credentials and loopback HTTP servers only.

112 tests pass; one candidate-guide check skips unless its path is supplied (passed separately against the Docs companion). TypeScript and build pass. Independent review passed; final-head CI required. The immutable historical guide fixture is unchanged.

Release boundary

Source repair only. No npm publish, installation, credential changes, approved-client replacement or Context identity preflight. Coordinator owns merge. Existing main publish workflow runs automatically on main pushes, so merging is publication-impacting; this PR does not change that workflow. Docs companion pins this source and states publication/installation remain unverified.

Final diagnostic correction: manual non-following fetch rejects 3xx with a fixed safe message, preserves original network failures and existing HTTP/API errors, and exposes no request or redirect details. Independent exact-commit review passed. Docs pins CLI 213de5156491e109c6b7243af4c8c17876370d93; final-head CI is distinct from earlier green results.