mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 23:43:15 +01:00
fix: invalid json body mistakenly quoted (#2449)
* fix: invalid json body mistakenly quoted * Update axios-instance.js * chore: better code for json header check --------- Co-authored-by: lohit <lohxt.space@gmail.com> Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
This commit is contained in:
parent
2191550061
commit
450b1d3ae3
@ -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
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user