diff --git a/packages/bruno-electron/src/ipc/network/axios-instance.js b/packages/bruno-electron/src/ipc/network/axios-instance.js index da1584d42..a292973fe 100644 --- a/packages/bruno-electron/src/ipc/network/axios-instance.js +++ b/packages/bruno-electron/src/ipc/network/axios-instance.js @@ -50,6 +50,19 @@ const checkConnection = (host, port) => function makeAxiosInstance() { /** @type {axios.AxiosInstance} */ const instance = axios.create({ + transformRequest: function transformRequest(data, headers) { + // doesn't apply the default transformRequest if the data is a string, so that axios doesn't add quotes see : + // https://github.com/usebruno/bruno/issues/2043 + // https://github.com/axios/axios/issues/4034 + const contentType = headers?.['Content-Type'] || headers?.['content-type'] || ''; + const hasJSONContentType = contentType.includes('json'); + if (typeof data === 'string' && hasJSONContentType) { + return data; + } + + axios.defaults.transformRequest.forEach((tr) => data = tr(data, headers)); + return data; + }, proxy: false });