diff --git a/package.json b/package.json index f9697693b..f0345bd50 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "node": ">=8.0.0" }, "browser": { + "https": false, "ws": false, "uws": false, "erlpack": false, diff --git a/src/rest/APIRequest.js b/src/rest/APIRequest.js index f39ab1cbf..ef13edefb 100644 --- a/src/rest/APIRequest.js +++ b/src/rest/APIRequest.js @@ -1,5 +1,8 @@ const querystring = require('querystring'); const snekfetch = require('snekfetch'); +const https = require('https'); + +if (https.Agent) var agent = new https.Agent({ keepAlive: true }); class APIRequest { constructor(rest, method, path, options) { @@ -20,7 +23,7 @@ class APIRequest { this.path += `?${queryString}`; } - const request = snekfetch[this.method](`${API}${this.path}`); + const request = snekfetch[this.method](`${API}${this.path}`, { agent }); if (this.options.auth !== false) request.set('Authorization', this.rest.getAuth()); if (this.options.reason) request.set('X-Audit-Log-Reason', encodeURIComponent(this.options.reason)); diff --git a/test/webpack.html b/test/webpack.html index 3bc9482fe..95d9636ce 100644 --- a/test/webpack.html +++ b/test/webpack.html @@ -5,7 +5,7 @@ - +