<h4 dir="auto">Describe the bug</h4>
<p dir="auto">Form uploads appear to have broken between v0.26 and v0.27. Requests that used to work without issue no longer work.</p>
<p dir="auto">Here is sample code that accepts a file and attempts to upload it to Cloudinary using form data.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export const upload = (file) =&gt; {
  const formData = new FormData();
  formData.set(&quot;file&quot;, file);
  formData.set(&quot;upload_preset&quot;, CLOUDINARY_UPLOAD_PRESET);

  return axios.post(
    `https://api.cloudinary.com/v1_1/${CLOUDINARY_CLOUD}/upload`,
    formData
  );
};"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-en">upload</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-s1">file</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">const</span> <span class="pl-s1">formData</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">FormData</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-s1">formData</span><span class="pl-kos">.</span><span class="pl-en">set</span><span class="pl-kos">(</span><span class="pl-s">"file"</span><span class="pl-kos">,</span> <span class="pl-s1">file</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-s1">formData</span><span class="pl-kos">.</span><span class="pl-en">set</span><span class="pl-kos">(</span><span class="pl-s">"upload_preset"</span><span class="pl-kos">,</span> <span class="pl-c1">CLOUDINARY_UPLOAD_PRESET</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-k">return</span> <span class="pl-s1">axios</span><span class="pl-kos">.</span><span class="pl-en">post</span><span class="pl-kos">(</span>
    <span class="pl-s">`https://api.cloudinary.com/v1_1/<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-c1">CLOUDINARY_CLOUD</span><span class="pl-kos">}</span></span>/upload`</span><span class="pl-kos">,</span>
    <span class="pl-s1">formData</span>
  <span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Inspecting the v0.26 request in with Chrome shows that it at least understands the content provided:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1100408/165413540-02c0e2bb-9676-448b-9a57-06c88a32a8c6.png"><img width="305" alt="image" src="https://user-images.githubusercontent.com/1100408/165413540-02c0e2bb-9676-448b-9a57-06c88a32a8c6.png" style="max-width: 100%;"></a></p>
<p dir="auto">Inspecting the v0.27 request in Chrome it appears to show more raw data - as if the form data wasn't handled correctly and is corrupted.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1100408/165413575-04b53606-bb97-4c70-95f7-8618c8ef4087.png"><img width="543" alt="image" src="https://user-images.githubusercontent.com/1100408/165413575-04b53606-bb97-4c70-95f7-8618c8ef4087.png" style="max-width: 100%;"></a></p>
<p dir="auto">I've attempted to use the alternate FormData syntax for v0.27 as suggested in the documentation but I have the same issue.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export const upload = (file) =&gt; {
  return axios.post(`https://api.cloudinary.com/v1_1/${CLOUDINARY_CLOUD}/upload`, {
    file: file,
    upload_preset: CLOUDINARY_UPLOAD_PRESET
  }, {
    headers: {
      &quot;Content-Type&quot;: &quot;multipart/form-data&quot;
    }
  });
};"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-en">upload</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-s1">file</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">return</span> <span class="pl-s1">axios</span><span class="pl-kos">.</span><span class="pl-en">post</span><span class="pl-kos">(</span><span class="pl-s">`https://api.cloudinary.com/v1_1/<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-c1">CLOUDINARY_CLOUD</span><span class="pl-kos">}</span></span>/upload`</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
    <span class="pl-c1">file</span>: <span class="pl-s1">file</span><span class="pl-kos">,</span>
    <span class="pl-c1">upload_preset</span>: <span class="pl-c1">CLOUDINARY_UPLOAD_PRESET</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
    <span class="pl-c1">headers</span>: <span class="pl-kos">{</span>
      <span class="pl-s">"Content-Type"</span>: <span class="pl-s">"multipart/form-data"</span>
    <span class="pl-kos">}</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<h4 dir="auto">To Reproduce</h4>
<p dir="auto">I couldn't get this running on RunKit because it's a Node environment, where my issue is in the browser using the native FormData vs the <code class="notranslate">form-data</code> npm package. However, the code below can be used (making a dummy request to <code class="notranslate">/api</code>) that would demonstrate the difference in request handing between the two affected versions.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export const upload = (file) =&gt; {
  const formData = new FormData();
  formData.set(&quot;file&quot;, file);
  formData.set(&quot;additional_parameter&quot;, &quot;additional_parameter&quot;);

  return axios.post(&quot;/api&quot;, formData);
};"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-en">upload</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-s1">file</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">const</span> <span class="pl-s1">formData</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">FormData</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-s1">formData</span><span class="pl-kos">.</span><span class="pl-en">set</span><span class="pl-kos">(</span><span class="pl-s">"file"</span><span class="pl-kos">,</span> <span class="pl-s1">file</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-s1">formData</span><span class="pl-kos">.</span><span class="pl-en">set</span><span class="pl-kos">(</span><span class="pl-s">"additional_parameter"</span><span class="pl-kos">,</span> <span class="pl-s">"additional_parameter"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-k">return</span> <span class="pl-s1">axios</span><span class="pl-kos">.</span><span class="pl-en">post</span><span class="pl-kos">(</span><span class="pl-s">"/api"</span><span class="pl-kos">,</span> <span class="pl-s1">formData</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<h4 dir="auto">Expected behavior</h4>
<p dir="auto">I would have expected the request with form data that worked in v0.26 to continue to work in v0.27 without issue.</p>
<h4 dir="auto">Environment</h4>
<ul dir="auto">
<li>Axios Version 0.27</li>
<li>Browser: Chrome</li>
<li>Browser Version: 100</li>
<li>Node.js Version: 18.0.0</li>
<li>OS: maxOS 12.3.1</li>
</ul>
<h4 dir="auto">Additional context/Screenshots</h4>
<p dir="auto">Add any other context about the problem here. If applicable, add screenshots to help explain.</p>
<h4 dir="auto">Summary</h4>
<p dir="auto">After upgrade from <strong>0.16.2</strong> to <strong>0.17.0</strong> I got error <code class="notranslate">window is undefined</code> when running in web worker at line:</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/axios/axios/blob/2c0e3183215d9a5fbc2ee8f35f459ac0e4d9f99c/lib/adapters/xhr.js#L27">axios/lib/adapters/xhr.js</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 27
      in
      <a data-pjax="true" class="commit-tease-sha" href="/axios/axios/commit/2c0e3183215d9a5fbc2ee8f35f459ac0e4d9f99c">2c0e318</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L27" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="27"></td>
          <td id="LC27" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">XMLHttpRequest</span> <span class="pl-c1">&amp;&amp;</span> </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">Changing order of conditions <code class="notranslate">typeof window !== 'undefined'</code> and <code class="notranslate">!window.XMLHttpRequest</code> fixes the error.</p>
<h4 dir="auto">Context</h4>
<ul dir="auto">
<li>axios version: <strong>0.17.0</strong></li>
<li>Environment: <strong>web worker in Chrome</strong></li>
</ul>
<h4 dir="auto">Notes</h4>
<p dir="auto">looking closer ar xhr.js:</p>
<ul dir="auto">
<li><code class="notranslate">typeof window</code> checks could be probably replaced with <code class="notranslate">typeof XMLHttpRequest</code> and <code class="notranslate">typeof btoa</code></li>
<li>There is <code class="notranslate">new XMLHttpRequest()</code> few lines prior <code class="notranslate">!window.XMLHttpRequest</code> check. I would expect, in case  <code class="notranslate">!window.XMLHttpRequest</code> is true, <code class="notranslate">new XMLHttpRequest()</code> will throw error before the check and the check is never performed</li>
</ul>