Repository navigation
Conversation
…e-safe - Follow 20 same-origin redirects before failing, as native fetch does (the guard stopped after 19). - Name the refused origin in the redirect error. Only the origin: a redirect's path and query can carry tokens. - Generated fetch code uses redirect: "manual" plus a 3xx check instead of redirect: "error". Cloudflare Workers throws a TypeError on "error", so every call from a Worker built from the snippet failed. - Test that the generated code returns an ordinary response unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main moved to 2.15.0 (withoneai#240); this fix ships as the next patch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @RachitSrivastava12, this is a good catch. I reproduced it on main: a cross-origin 307 from the API host sent I pushed a few changes to your branch so we can ship it:
CI is green on Ubuntu and Windows for Node 22, 24 and 26. Thanks again for the report and the thorough tests. |
Thanks @paulkr! Appreciate you checking this and making the compatibility fixes. I also opened #241 to address flow actions continuing after timeout, with cancellation propagation and regression tests. Would appreciate a look when you get a chance! |
Native
fetchstrips standard auth headers on cross-origin redirects, but custom headers likex-one-secretandx-one-connection-keycan still be forwarded.This change adds explicit redirect handling to
OneApiso credential-bearing requests only follow same-origin redirects.It also sets
redirect: "error"in the generated fetch examples, since those requests carry the same credentials.Added regression tests for cross-origin redirects, relative URLs, redirect loops, malformed locations, and 301/302/303/307/308 behavior.
Tested
TMPDIR=/private/tmp npm test— 871 passednpm run typechecknpm run buildgit diff --checkI reproduced the header forwarding behavior locally with dummy credentials. I haven't verified whether the hosted passthrough backend returns upstream redirects to the CLI.