<p dir="auto"><strong>Describe the bug</strong></p>
<p dir="auto">I started to write JEST test run by nodejs 13.11. This statement was failing:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="let response = await axios.get(`${API}/users/1234`, getAuthHeader()); 
function getAuthHeader() {
    const config = { headers: { } };
    config.headers.Authorization = &quot;bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxZTQwdjBiMWo1Iiwibmlja25hbWUiOiJsaXRlcmFrbCIsInB3ZFRpbWVzdGFtcCI6IjIwMjAtMDMtMjJUMTE6MTA6NDkuNDg2WiIsInJvbGVzIjpbImFkbWluOnBvbGwiXSwiaWF0IjoxNTg2NjkwNzc2LCJleHAiOjE1ODkzNjkxNzZ9.N5MfpZ9i9Sjv-izdYItR4gXCmzVkqkuVcVSEL_6Q89c&quot;;
    return config;
}"><pre class="notranslate"><code class="notranslate">let response = await axios.get(`${API}/users/1234`, getAuthHeader()); 
function getAuthHeader() {
    const config = { headers: { } };
    config.headers.Authorization = "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxZTQwdjBiMWo1Iiwibmlja25hbWUiOiJsaXRlcmFrbCIsInB3ZFRpbWVzdGFtcCI6IjIwMjAtMDMtMjJUMTE6MTA6NDkuNDg2WiIsInJvbGVzIjpbImFkbWluOnBvbGwiXSwiaWF0IjoxNTg2NjkwNzc2LCJleHAiOjE1ODkzNjkxNzZ9.N5MfpZ9i9Sjv-izdYItR4gXCmzVkqkuVcVSEL_6Q89c";
    return config;
}
</code></pre></div>
<p dir="auto">with the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Network Error
  at createError (node_modules/axios/lib/core/createError.js:16:15)
  at XMLHttpRequest.handleError (node_modules/axios/lib/adapters/xhr.js:83:14)
  at XMLHttpRequest.&lt;anonymous&gt; (node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js:33:32)
  at innerInvokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:316:27)
  at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:267:3)
  at XMLHttpRequestEventTargetImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:214:9)
  at fireAnEvent (node_modules/jsdom/lib/jsdom/living/helpers/events.js:17:36)
  at requestErrorSteps (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:121:3)
  at Object.dispatchError (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:51:3)
  at EventEmitter.&lt;anonymous&gt; (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:675:20)
  at Request.&lt;anonymous&gt; (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:384:47)
  at Request.onRequestError (node_modules/request/request.js:877:8)

Error: Error: Parse Error: Duplicate Content-Length
    at Object.dispatchError (C:\Users\leos\WebstormProjects\nano-options\node_modules\jsdom\lib\jsdom\living\xhr-utils.js:54:19)
    at EventEmitter.&lt;anonymous&gt; (C:\Users\leos\WebstormProjects\nano-options\node_modules\jsdom\lib\jsdom\living\xmlhttprequest.js:675:20)
    at EventEmitter.emit (events.js:327:22)
    at Request.&lt;anonymous&gt; (C:\Users\leos\WebstormProjects\nano-options\node_modules\jsdom\lib\jsdom\living\xhr-utils.js:384:47)
    at Request.emit (events.js:315:20)
    at Request.onRequestError (C:\Users\leos\WebstormProjects\nano-options\node_modules\request\request.js:877:8)
    at ClientRequest.emit (events.js:315:20)
    at Socket.socketOnData (_http_client.js:486:9)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:297:12) undefined"><pre class="notranslate"><code class="notranslate">Network Error
  at createError (node_modules/axios/lib/core/createError.js:16:15)
  at XMLHttpRequest.handleError (node_modules/axios/lib/adapters/xhr.js:83:14)
  at XMLHttpRequest.&lt;anonymous&gt; (node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js:33:32)
  at innerInvokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:316:27)
  at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:267:3)
  at XMLHttpRequestEventTargetImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:214:9)
  at fireAnEvent (node_modules/jsdom/lib/jsdom/living/helpers/events.js:17:36)
  at requestErrorSteps (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:121:3)
  at Object.dispatchError (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:51:3)
  at EventEmitter.&lt;anonymous&gt; (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:675:20)
  at Request.&lt;anonymous&gt; (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:384:47)
  at Request.onRequestError (node_modules/request/request.js:877:8)

Error: Error: Parse Error: Duplicate Content-Length
    at Object.dispatchError (C:\Users\leos\WebstormProjects\nano-options\node_modules\jsdom\lib\jsdom\living\xhr-utils.js:54:19)
    at EventEmitter.&lt;anonymous&gt; (C:\Users\leos\WebstormProjects\nano-options\node_modules\jsdom\lib\jsdom\living\xmlhttprequest.js:675:20)
    at EventEmitter.emit (events.js:327:22)
    at Request.&lt;anonymous&gt; (C:\Users\leos\WebstormProjects\nano-options\node_modules\jsdom\lib\jsdom\living\xhr-utils.js:384:47)
    at Request.emit (events.js:315:20)
    at Request.onRequestError (C:\Users\leos\WebstormProjects\nano-options\node_modules\request\request.js:877:8)
    at ClientRequest.emit (events.js:315:20)
    at Socket.socketOnData (_http_client.js:486:9)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:297:12) undefined
</code></pre></div>
<p dir="auto">But when the stament was GET without AUTH header, the code was working well. The same request from Postman with AUTH header was working well too.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="let response = await axios.get(`${API}/users/1234`);"><pre class="notranslate"><code class="notranslate">let response = await axios.get(`${API}/users/1234`);
</code></pre></div>
<p dir="auto">Later I realized that Axios sends OPTIONS method instead of GET and server returns CORS headers, 200 status code, no data and content-length: '0'.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  message: &lt;ref *1&gt; uWS.HttpResponse {
    __request: uWS.HttpRequest {
      rawPath: '/v1/users/:userId',
      method: 'OPTIONS',
      path: '/v1/users/1e5ngnj1e6',
      url: '/v1/users/1e5ngnj1e6',
      originalUrl: '/v1/users/1e5ngnj1e6',
      baseUrl: '',
      __response: [Circular *1],
      getIP: [Function: getIP],
      headers: {
        origin: 'http://localhost',
        'access-control-request-method': 'GET',
        'access-control-request-headers': 'Authorization',
        'user-agent': 'Mozilla/5.0 (win32) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/15.2.1',
        host: '192.168.157.241:3000',
        'content-length': '0',
        connection: 'keep-alive'
      },
      cookies: undefined,
      params: { userId: '1e5ngnj1e6' },
      query: undefined
    },
    rawStatusCode: 200,
    config: {
      host: '0.0.0.0',
      port: 3000,
      https: false,
      configureAjv: undefined,
      setAjv: [Function (anonymous)],
      swagger: undefined,
      _errorHandler: [Function (anonymous)],
      _notFoundHandler: [Function (anonymous)]
    },
    abortHandler: true
  },"><pre class="notranslate"><code class="notranslate">  message: &lt;ref *1&gt; uWS.HttpResponse {
    __request: uWS.HttpRequest {
      rawPath: '/v1/users/:userId',
      method: 'OPTIONS',
      path: '/v1/users/1e5ngnj1e6',
      url: '/v1/users/1e5ngnj1e6',
      originalUrl: '/v1/users/1e5ngnj1e6',
      baseUrl: '',
      __response: [Circular *1],
      getIP: [Function: getIP],
      headers: {
        origin: 'http://localhost',
        'access-control-request-method': 'GET',
        'access-control-request-headers': 'Authorization',
        'user-agent': 'Mozilla/5.0 (win32) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/15.2.1',
        host: '192.168.157.241:3000',
        'content-length': '0',
        connection: 'keep-alive'
      },
      cookies: undefined,
      params: { userId: '1e5ngnj1e6' },
      query: undefined
    },
    rawStatusCode: 200,
    config: {
      host: '0.0.0.0',
      port: 3000,
      https: false,
      configureAjv: undefined,
      setAjv: [Function (anonymous)],
      swagger: undefined,
      _errorHandler: [Function (anonymous)],
      _notFoundHandler: [Function (anonymous)]
    },
    abortHandler: true
  },
</code></pre></div>
<p dir="auto">Then a guy on StackOverflow asked me for NodeJS version. When I downgraded to NodeJS v12.16.2, this error disappeared. But I still see only OPTIONS method and GET does not follow.</p>
<p dir="auto"><strong>To Reproduce</strong></p>
<p dir="auto">Here is the minimum reproducible repository: <a href="https://github.com/literakl/nano-options/blob/master/api.int.test.js">https://github.com/literakl/nano-options/blob/master/api.int.test.js</a></p>
<p dir="auto"><strong>Expected behavior</strong></p>
<p dir="auto">GET with Authorization header will be sent to server. The same code works for me well with Vue in Chrome browser.</p>
<p dir="auto"><strong>Environment:</strong></p>
<ul dir="auto">
<li>Axios Version 0.19.2</li>
<li>OS: Windows 10</li>
<li>Browser N/A</li>
<li>Browser Version N/a</li>
<li>Additional Library Versions NodeJS 13.11, 12.16.2</li>
</ul>
<p dir="auto"><strong>Additional context/Screenshots</strong></p>
<p dir="auto"><a href="https://stackoverflow.com/questions/61173165/duplicate-content-length-with-axios-running-in-jest#61173165" rel="nofollow">https://stackoverflow.com/questions/61173165/duplicate-content-length-with-axios-running-in-jest#61173165</a></p>
<p dir="auto">#### Summary</p>
<p dir="auto">The following node.js app using Axios works correctly on Windows and Mac:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="var SERVER_URL = 'http://localhost:3000';

var axios = require(&quot;axios&quot;);

function getBooks() {
    return axios
        .get(SERVER_URL + '/books')
        .then(function(response) {
            return response.data;
        });
}

getBooks()
    .then(function(books) {
        console.log(JSON.stringify(books, null, '    '));
    });"><pre class="notranslate"><code class="notranslate">var SERVER_URL = 'http://localhost:3000';

var axios = require("axios");

function getBooks() {
    return axios
        .get(SERVER_URL + '/books')
        .then(function(response) {
            return response.data;
        });
}

getBooks()
    .then(function(books) {
        console.log(JSON.stringify(books, null, '    '));
    });
</code></pre></div>
<p dir="auto">However, if I run it on a Windows 7 or Windows 10 VDI (essentially a virtual machine), it fails with the following error message:</p>
<blockquote>
<p dir="auto">(node:12000) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Request failed with status code 504</p>
</blockquote>
<p dir="auto"><strong>If I replace the axios call with node-fetch, the error goes away and the fetch works.</strong> What could be the problem with axios or the way I am using it?</p>
<p dir="auto">#### Context</p>
<ul dir="auto">
<li>axios version: v0.16.2</li>
<li>Environment: node v6.11.0, windows 7, Windows 10 running in a VDI</li>
</ul>