-
Notifications
You must be signed in to change notification settings - Fork 30
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
Specifying http proxy changed in Node@18 and 20 #1103
Comments
Thanks for reaching out. @sebastienlevert and I were chatting about that earlier and he mentioned he made it work. I'll let him provide the specifics when he has time (as you know I'm traveling right now and don't have time to dig into this) |
Just to confirm... This is for Graph JS v3, right? We donc have the middleware initialization anymore IIRC. As we won't be adding new features over there, I highly doubt we'll get to this. |
This change affects any code that relies on Node's fetch. I noticed it in Graph JS SDK v3 but if the new TypeScript SDK also uses Node.js fetch, then it would also have the same issue. |
Since this initial post, our plans have changed multiple times. We now planning a full depreciation of the "old" JS SDK, which means the "new" TypeScript SDK and kiota dependencies won't have any dependencies on it. The client factory now supports providing a fetch callback Consumers should simply need to do something like this: const proxy = new HttpsProxyAgent('http://168.63.76.32:3128');
const customFetch = (request: string, init: RequestInit) => fetch(request, {...init, agent: proxy});
const httpClient = KiotaClientFactory.create(customFetch); // additional middleware configuration here
const requestAdapter = new DefaultRequestAdapter(authenticationProvider, undefined, undefined, httpClient);
const apiClient = new APIClient(requestAdapter); Of course, we can add shorthands in graph core and service libraries to reduce the number of calls here, the important thing is the capability is available natively. We might also want to advise customers to take an additional dependency on https-proxy-agent, more context Assuming this tab gets updated (it should really say JavaScript to be consistent with generated doc snippets), does that address your concern @waldekmastykarz ? |
Yes it does! I appreciate you being mindful of this requirement, that many large organization need for their apps. |
Since v18, Node ships with a native fetch client. This client requires a different way to specify an HTTP proxy than what we've been supporting in our SDKs so far.
To specify an HTTP proxy for Node's fetch, you need to use the following code (tested on Node v18.19 and v20.11):
What's noteworthy:
We should update our FetchOptions interface to support specifying dispatcher.
The text was updated successfully, but these errors were encountered: