Skip to content

Commit

Permalink
refactor: use node-fetch-native/proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Dec 24, 2023
1 parent 00c3ca1 commit efa4f7a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"citty": "^0.1.5",
"consola": "^3.2.3",
"defu": "^6.1.3",
"node-fetch-native": "^1.5.1",
"node-fetch-native": "^1.6.1",
"nypm": "^0.3.3",
"ohash": "^1.1.3",
"pathe": "^1.1.1",
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions src/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { homedir } from "node:os";
import { promisify } from "node:util";
import type { Agent } from "node:http";
import { relative, resolve } from "pathe";
import { fetch } from "node-fetch-native";
import { createProxy } from "node-fetch-native/proxy";
import { fetch } from "node-fetch-native/proxy";
import type { GitInfo } from "./types";

export async function download(
Expand Down Expand Up @@ -75,13 +74,6 @@ export async function sendFetch(
url: string,
options: InternalFetchOptions = {},
) {
// Add proxy support
// https://github.com/unjs/node-fetch-native?tab=readme-ov-file#proxy-support
options = {
...createProxy(),
...options,
};

// https://github.com/nodejs/undici/issues/1305
if (options.headers?.["sec-fetch-mode"]) {
options.mode = options.headers["sec-fetch-mode"] as any;
Expand Down

0 comments on commit efa4f7a

Please sign in to comment.