ijpiantanida / talkback

A simple HTTP proxy that records and playbacks requests
MIT License
283 stars 41 forks source link

feat: proxy agent with redirect manual #96

Open tristanrobert opened 1 month ago

tristanrobert commented 1 month ago

When using corporate proxy agent in fetchOptions, some endpoints having cloudfare in front and it responds with a 301. To avoid this issue it is not recommended to add infetchOptions: {redirect: 'follow', follow: 1} because with POST method it responds with 404 issue (body may be malformed). It would be usefull to keep redirect: 'manual' and have an option to do this redirect in the talkback proxy as node-fetch recommends it as BASIC fetch specification: https://www.npmjs.com/package/node-fetch#manual-redirect

ijpiantanida commented 1 month ago

I'm not sure I'm understanding the issue.

Talkback by default (code) already uses redirect: 'manual'.

I don't see a reason why you would want talkback to follow redirects for you, as talkback is trying to behave like your origin. If your origin is returning a 301, then you'd want that to reach to your application so using talkback is no different than using your real origin.

What am I missing?

tristanrobert commented 1 month ago

I use undici request and you use node-fetch. Behind corporate proxy, with undici request http response codes are 200 and with talkback (node-fetch) there are 301. Endpoints are https://notion.so. I investigate to show you the two complete HTTP requests done and compare it.

ijpiantanida commented 1 month ago

yes if you could post the different HTTP request/responses that would help.

Maybe undici is configured to follow redirects automatically?

And just to make sure, is this the setup that you are comparing? [your app] -> [proxy] -> [notion] vs [your app] -> [talkback] -> [proxy] -> [notion]?