You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d3d7f39
Browse filesBrowse the repository at this point in the historyBrowse files
feat(web-incoming): implement native followRedirects support
Add redirect following (301/302/303/307/308) directly in the stream pass
without external dependencies. Supports `true` (max 5) or numeric limit.
301/302/303 change method to GET; 307/308 preserve method and body.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Copy file name to clipboardExpand all lines: AGENTS.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,6 +66,12 @@ proxyFetch(addr, request) → http.request to addr → Web Response
66
66
-`proxyReq` event is intentionally skipped when request has `expect` header (`100-continue` advisory coverage).
67
67
-`selfHandleResponse: true` skips outgoing passes and auto-pipe; callers must finish the response in `proxyRes`.
68
68
-`proxyTimeout` aborts upstream request and surfaces timeout errors (tested as `ECONNRESET`).
69
+
-`followRedirects: true | number` enables native redirect following (301/302/303/307/308). `true` = max 5 hops, number = custom max.
70
+
- On 301/302/303 redirects, method changes to GET and request body is dropped.
71
+
- On 307/308 redirects, original method and body are preserved (body is buffered on first request for replay).
72
+
-`proxyRes` event fires only for the final (non-redirect) response; `proxyReq` fires for each request including redirects.
73
+
- Sensitive headers (`authorization`, `cookie`) are stripped on cross-origin redirects.
74
+
- When `followRedirects` is enabled, the request body is tee'd (written to proxy request and buffered simultaneously) rather than piped.
69
75
70
76
### WebSocket middleware semantics
71
77
@@ -126,7 +132,7 @@ pnpm test # Lint + typecheck + tests with coverage
126
132
### Test expectations and parity
127
133
128
134
- The suite includes legacy parity tests ported from `http-party/node-http-proxy` plus project-specific tests (`test/server.test.ts`, `test/fetch.test.ts`, `test/types.test-d.ts`).
129
-
-`followRedirects`parity is intentionally pending/todo and currently unsupported.
135
+
-`followRedirects` is natively implemented (no external dependency). See behavioral notes below.
130
136
- HTTPS tests rely on local fixtures in `test/fixtures/agent2-*.pem`.
|`buffer`|`stream.Stream`| — | Stream to use as request body instead of the incoming request |
104
-
105
-
> [!NOTE]
106
-
> `followRedirects` from [node-http-proxy](https://github.com/http-party/node-http-proxy) is **not** supported.
/** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */
67
67
selfHandleResponse?: boolean;
68
+
/** Follow HTTP redirects from target. `true` = max 5 hops; number = custom max. */
0 commit comments