Skip to content

Commit c0b40c0

Browse files
committed
refactor(create-react-router): use native Fetch
1 parent f7bc402 commit c0b40c0

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

packages/create-react-router/copy-template.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,11 @@ import fs from "node:fs";
44
import path from "node:path";
55
import stream from "node:stream";
66
import { promisify } from "node:util";
7-
import { fetch } from "@remix-run/web-fetch";
87
import gunzip from "gunzip-maybe";
98
import tar from "tar-fs";
10-
import { ProxyAgent } from "proxy-agent";
119

1210
import { color, isUrl } from "./utils";
1311

14-
const defaultAgent = new ProxyAgent();
15-
const httpsAgent = new ProxyAgent();
16-
httpsAgent.protocol = "https:";
17-
function agent(url: string) {
18-
return new URL(url).protocol === "https:" ? httpsAgent : defaultAgent;
19-
}
20-
2112
export async function copyTemplate(
2213
template: string,
2314
destPath: string,
@@ -234,10 +225,7 @@ async function downloadAndExtractTarball(
234225
? `https://api.github.com/repos/${info.owner}/${info.name}/releases/latest`
235226
: `https://api.github.com/repos/${info.owner}/${info.name}/releases/tags/${info.tag}`;
236227

237-
let response = await fetch(releaseUrl, {
238-
agent: agent("https://api.github.com"),
239-
headers,
240-
});
228+
let response = await fetch(releaseUrl, { headers });
241229

242230
if (response.status !== 200) {
243231
throw new CopyTemplateError(
@@ -274,10 +262,7 @@ async function downloadAndExtractTarball(
274262
resourceUrl = `https://api.github.com/repos/${info.owner}/${info.name}/releases/assets/${assetId}`;
275263
headers.Accept = "application/octet-stream";
276264
}
277-
let response = await fetch(resourceUrl, {
278-
agent: agent(resourceUrl),
279-
headers,
280-
});
265+
let response = await fetch(resourceUrl, { headers });
281266

282267
if (!response.body || response.status !== 200) {
283268
if (token) {

packages/create-react-router/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@
3636
}
3737
},
3838
"dependencies": {
39-
"@remix-run/web-fetch": "^4.4.2",
4039
"arg": "^5.0.1",
4140
"chalk": "^4.1.2",
4241
"execa": "5.1.1",
4342
"gunzip-maybe": "^1.4.2",
4443
"log-update": "^5.0.1",
45-
"proxy-agent": "^6.3.0",
4644
"semver": "^7.3.7",
4745
"sisteransi": "^1.0.5",
4846
"sort-package-json": "^1.55.0",

0 commit comments

Comments
 (0)