Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions packages/create-react-router/copy-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@ import fs from "node:fs";
import path from "node:path";
import stream from "node:stream";
import { promisify } from "node:util";
import { fetch } from "@remix-run/web-fetch";
import gunzip from "gunzip-maybe";
import tar from "tar-fs";
import { ProxyAgent } from "proxy-agent";

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

Comment thread
MichaelDeBoey marked this conversation as resolved.
const defaultAgent = new ProxyAgent();
const httpsAgent = new ProxyAgent();
httpsAgent.protocol = "https:";
function agent(url: string) {
return new URL(url).protocol === "https:" ? httpsAgent : defaultAgent;
}

export async function copyTemplate(
template: string,
destPath: string,
Expand Down Expand Up @@ -234,10 +225,7 @@ async function downloadAndExtractTarball(
? `https://api.github.com/repos/${info.owner}/${info.name}/releases/latest`
: `https://api.github.com/repos/${info.owner}/${info.name}/releases/tags/${info.tag}`;

let response = await fetch(releaseUrl, {
agent: agent("https://api.github.com"),
headers,
});
let response = await fetch(releaseUrl, { headers });

if (response.status !== 200) {
throw new CopyTemplateError(
Expand Down Expand Up @@ -274,10 +262,7 @@ async function downloadAndExtractTarball(
resourceUrl = `https://api.github.com/repos/${info.owner}/${info.name}/releases/assets/${assetId}`;
headers.Accept = "application/octet-stream";
}
let response = await fetch(resourceUrl, {
agent: agent(resourceUrl),
headers,
});
let response = await fetch(resourceUrl, { headers });

if (!response.body || response.status !== 200) {
if (token) {
Expand Down
2 changes: 0 additions & 2 deletions packages/create-react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@
}
},
"dependencies": {
"@remix-run/web-fetch": "^4.4.2",
"arg": "^5.0.1",
"picocolors": "^1.1.1",
"execa": "5.1.1",
"gunzip-maybe": "^1.4.2",
"log-update": "^5.0.1",
"proxy-agent": "^6.3.0",
"semver": "^7.3.7",
"sisteransi": "^1.0.5",
"sort-package-json": "^1.55.0",
Expand Down
Loading
Loading