-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
87 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type * as http from "node:http"; | ||
import type * as https from "node:https"; | ||
import type * as undici from "undici"; | ||
|
||
export type ProxyOptions = { url?: string }; | ||
|
||
export declare const createProxy: (opts?: ProxyOptions) => { | ||
agent: http.Agent | https.Agent | undefined; | ||
dispatcher: undici.Dispatcher | undefined; | ||
}; | ||
|
||
export declare const createFetch: ( | ||
proxyOptions?: ProxyOptions, | ||
) => typeof globalThis.fetch; | ||
|
||
export declare const fetch: typeof globalThis.fetch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from "./lib/proxy.mjs"; | ||
export * from "./lib/proxy"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,5 @@ | ||
import { fetch } from "node-fetch-native"; // or use global fetch | ||
import { createProxy } from "node-fetch-native/proxy"; | ||
import { createFetch } from "node-fetch-native/proxy"; | ||
|
||
process.env.HTTPS_PROXY = "http://localhost:9080"; | ||
process.env.DEBUG = "true"; | ||
const fetch = createFetch({ url: "http://localhost:9080" }); | ||
|
||
const proxy = createProxy(); | ||
|
||
const res = await fetch("https://icanhazip.com", { | ||
...proxy, | ||
}); | ||
|
||
console.log(await res.text()); | ||
console.log(await fetch("https://icanhazip.com").then((r) => r.text())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters