From 0035ef4f397d0ab0186b8ff14b475249a6e04a23 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Thu, 24 Aug 2023 12:11:23 -0600 Subject: [PATCH] Fix HTTPS signing for POSTS --- core/http_util.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/http_util.js b/core/http_util.js index 7ca90966..e737da92 100644 --- a/core/http_util.js +++ b/core/http_util.js @@ -2,7 +2,8 @@ const { Errors } = require('./enig_error.js'); // deps const { isString, isObject, truncate } = require('lodash'); -const { https } = require('follow-redirects'); +const httpsNoRedirects = require('node:https'); +const { https: httpsWithRedirects } = require('follow-redirects'); const httpSignature = require('http-signature'); const crypto = require('crypto'); @@ -78,6 +79,13 @@ function _makeRequest(url, options, cb) { } }; + let https; + if (options.method === 'POST' || options.sign) { + https = httpsNoRedirects; + } else { + https = httpsWithRedirects; + } + const req = https.request(url, options, res => { let body = []; res.on('data', d => {