summaryrefslogtreecommitdiff
path: root/packages/webapi
diff options
context:
space:
mode:
Diffstat (limited to 'packages/webapi')
-rw-r--r--packages/webapi/package.json2
-rw-r--r--packages/webapi/run/build.js2
-rw-r--r--packages/webapi/src/lib/fetch.ts7
3 files changed, 10 insertions, 1 deletions
diff --git a/packages/webapi/package.json b/packages/webapi/package.json
index 1d8727c25..5b94c4429 100644
--- a/packages/webapi/package.json
+++ b/packages/webapi/package.json
@@ -50,6 +50,7 @@
"bugs": "https://github.com/withastro/astro/issues",
"homepage": "https://github.com/withastro/astro/tree/main/packages/webapi#readme",
"dependencies": {
+ "global-agent": "^3.0.0",
"node-fetch": "^3.2.5"
},
"devDependencies": {
@@ -58,6 +59,7 @@
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-typescript": "^8.3.2",
"@types/chai": "^4.3.1",
+ "@types/global-agent": "^2.1.1",
"@types/mocha": "^9.1.1",
"@types/node": "^14.18.21",
"@ungap/structured-clone": "^0.3.4",
diff --git a/packages/webapi/run/build.js b/packages/webapi/run/build.js
index d81f5e609..42571763a 100644
--- a/packages/webapi/run/build.js
+++ b/packages/webapi/run/build.js
@@ -178,7 +178,7 @@ async function build() {
inputOptions: {
input: 'src/polyfill.ts',
plugins: plugins,
- external: ['node-fetch'],
+ external: ['node-fetch', 'global-agent'],
onwarn(warning, warn) {
if (warning.code !== 'UNRESOLVED_IMPORT') warn(warning)
},
diff --git a/packages/webapi/src/lib/fetch.ts b/packages/webapi/src/lib/fetch.ts
index b099e44af..9c1f7c446 100644
--- a/packages/webapi/src/lib/fetch.ts
+++ b/packages/webapi/src/lib/fetch.ts
@@ -2,6 +2,13 @@ import type { RequestInit } from 'node-fetch'
import { default as nodeFetch, Headers, Request, Response } from 'node-fetch'
import Stream from 'node:stream'
import * as _ from './utils'
+import {
+ bootstrap as bootstrapGlobalAgent
+} from 'global-agent';
+
+bootstrapGlobalAgent({
+ environmentVariableNamespace: '',
+});
export { Headers, Request, Response }