From 643151f0cf3f8bf8b141e61ec61201f9deaa83d4 Mon Sep 17 00:00:00 2001 From: Arthur Buldauskas Date: Thu, 26 Oct 2023 13:32:48 -0400 Subject: [PATCH] Fix #39, turn off cors (#40) - Fix #39 - Address issue with `cors` mode see https://github.com/httptoolkit/mockttp/issues/156 --- CHANGELOG.md | 5 +++++ package.json | 2 +- src/server/index.mjs | 1 - src/utils/serialize.mjs | 7 +++++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f9425b..ed87f0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.0.30 - Turn off cors mode + +- Turn off cors mode fix issue with multi headers +- Fix #39 + ## 0.0.29 - Fix SKPI Fingerprint, minor improvements - Fix SKPI fingerprint diff --git a/package.json b/package.json index 64db0cb..bf3dce1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jambox", - "version": "0.0.29", + "version": "0.0.30", "description": "Tool for recording and playing back HTTP requests.", "bin": { "jam": "./jam.mjs", diff --git a/src/server/index.mjs b/src/server/index.mjs index 2764fea..b8dfb7b 100644 --- a/src/server/index.mjs +++ b/src/server/index.mjs @@ -18,7 +18,6 @@ const getServices = (filesystem) => { const ews = expessWS(app); const cache = new Cache(); const proxy = mockttp.getLocal({ - cors: true, recordTraffic: false, suggestChanges: false, https: { diff --git a/src/utils/serialize.mjs b/src/utils/serialize.mjs index 75a960f..fb04df7 100644 --- a/src/utils/serialize.mjs +++ b/src/utils/serialize.mjs @@ -37,9 +37,12 @@ export const updateResponse = async (prev, curr) => { ...rest, }; - // Update the final buffer and content length result.body.buffer = buffer; - result.headers['content-length'] = buffer.length; + + // Update the final buffer and content length + if ('content-length' in result.headers) { + result.headers['content-length'] = buffer.length; + } return result; };