New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Support async use of the beforeRedirect option #240
Comments
Thanks @olebor, that makes sense. For backward compatibility, we could activate async support if either a |
Cool! To clarify: Since the lib itself calls the function, it would be the lib passing the Adding a fourth Am I missing something? Personally, I think the promise pattern is the cleanest one. |
Yes; although probably 4 arguments wouldn't be great to have. But we can discuss/change that once we have concrete code.
Ah well they shouldn't, it wasn't in our interface 😅
Yes, but follow-redirects has a long compatibility history, with even some earlier versions of Node that did not have promises yet. But feel free to take a first stab at it, and we can discuss it from there. |
I would like the
beforeRedirect
method to support async use cases. A possible implementation could be that it will wait if a promise is returned in the function. I believe that would not break any current uses of it.I need this for a scenario where I do server-side requests to endpoints specified by untrusted users. The plan is to validate the requests to ensure they don't point to anywhere I don't want them to (for example, inside the infrastructure/SSRF). I would need to validate all redirect steps (resolve DNS, etc.), not only the initial URL.
If this is a feature you think could be useful, I would be happy to take a shot at it.
The text was updated successfully, but these errors were encountered: