-
Notifications
You must be signed in to change notification settings - Fork 569
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
Set proxy for some fetch request (not all) #1350
Comments
cc @ronag |
import { ProxyAgent } from 'undici';
const client = new ProxyAgent('localhost:3000');
const response = await fetch("https://myserver.com", {
dispatcher: client
}); If you are using node v18.2.0 or above, this will work using node's fetch. Otherwise, you need to import |
@KhafraDev sorry for reviving this thread, but is this a standard thing? I couldn't find any "dispatcher" in Fetch API docs. It also isn't listed in Typescript "lib" types for "RequestInit": |
It's a node-specific extension. I wouldn't recommend using the dom types in node; @types/node will be more correct. https://github.com/nodejs/undici?tab=readme-ov-file#undicifetchinput-init-promise |
I apologize if this has already been implemented or issue created, but I could not find this usage in the documentation.
This would solve...
I would like to specify a proxy for each fetch run.
The implementation should look like...
Deno implements as follows PR:
denoland/deno#10907
In undici, it would become as follows...?
(Is ProxyAgent better than Client?)
The text was updated successfully, but these errors were encountered: