talkback icon indicating copy to clipboard operation
talkback copied to clipboard

feat: proxy agent with redirect manual

Open tristanrobert opened this issue 1 year ago • 3 comments

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 in fetchOptions: {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

tristanrobert avatar Jul 18 '24 15:07 tristanrobert

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?

ijpiantanida avatar Jul 19 '24 01:07 ijpiantanida

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.

tristanrobert avatar Jul 19 '24 15:07 tristanrobert

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]?

ijpiantanida avatar Jul 19 '24 16:07 ijpiantanida