From 9579bad1d38fe5eb6e191eb582dd3f55f4d1489a Mon Sep 17 00:00:00 2001 From: Lawliet <37376096+L-Hknu@users.noreply.github.com> Date: Tue, 10 May 2022 01:20:33 +0800 Subject: [PATCH] The content type option is left to the developer (#4550) * The content type option is left to the developer If the browser recognizes the fault, it can protect the developer Although I don't think Axios itself should interfere with developers' choices This parameter is for compatibility with historical issues * Update xhr.js Co-authored-by: Jay --- lib/adapters/xhr.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/adapters/xhr.js b/lib/adapters/xhr.js index 337b7a015a..5575925285 100644 --- a/lib/adapters/xhr.js +++ b/lib/adapters/xhr.js @@ -28,8 +28,10 @@ module.exports = function xhrAdapter(config) { } } - if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) { - delete requestHeaders['Content-Type']; // Let the browser set it + + if (utils.isFormData(requestData) && utils.isStandardBrowserEnv() && !config.defineContentType ) { + // Let the browser set the content type should it not be set + delete requestHeaders['Content-Type']; } var request = new XMLHttpRequest();