<p dir="auto"><strong>Describe the bug</strong><br>
After upgrading axios from 0.19.0 to 0.19.1 all tests that use nock got broken. They now produce the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Error: Cross origin http://localhost forbidden"><pre lang="text" class="notranslate"><code class="notranslate">Error: Cross origin http://localhost forbidden
</code></pre></div>
<p dir="auto"><strong>To Reproduce</strong><br>
Repo with minimal test case that reproduces the issue: <a href="https://github.com/EvgenyOrekhov/js-framework/tree/axios-bug">https://github.com/EvgenyOrekhov/js-framework/tree/axios-bug</a>.</p>
<p dir="auto">Note that <a href="https://github.com/EvgenyOrekhov/js-framework/tree/150ebe811c9531b7699c030e7921514e469fe84e">previous commit</a> (which has axios 0.19.0) works fine, the test passes.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import axios from &quot;axios&quot;;
import nock from &quot;nock&quot;;

it(&quot;makes HTTP requests&quot;, async done =&gt; {
  const scope = nock(&quot;https://example.com/foo/&quot;)
    .get(&quot;/bar&quot;)
    .reply(200, { foo: &quot;bar&quot; });

  await axios.get(&quot;https://example.com/foo/bar&quot;);

  scope.done();
  done();
});"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">axios</span> <span class="pl-k">from</span> <span class="pl-s">"axios"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s1">nock</span> <span class="pl-k">from</span> <span class="pl-s">"nock"</span><span class="pl-kos">;</span>

<span class="pl-en">it</span><span class="pl-kos">(</span><span class="pl-s">"makes HTTP requests"</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-s1">done</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">const</span> <span class="pl-s1">scope</span> <span class="pl-c1">=</span> <span class="pl-en">nock</span><span class="pl-kos">(</span><span class="pl-s">"https://example.com/foo/"</span><span class="pl-kos">)</span>
    <span class="pl-kos">.</span><span class="pl-en">get</span><span class="pl-kos">(</span><span class="pl-s">"/bar"</span><span class="pl-kos">)</span>
    <span class="pl-kos">.</span><span class="pl-en">reply</span><span class="pl-kos">(</span><span class="pl-c1">200</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">foo</span>: <span class="pl-s">"bar"</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-k">await</span> <span class="pl-s1">axios</span><span class="pl-kos">.</span><span class="pl-en">get</span><span class="pl-kos">(</span><span class="pl-s">"https://example.com/foo/bar"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-s1">scope</span><span class="pl-kos">.</span><span class="pl-en">done</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-en">done</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>
<p dir="auto"><strong>Expected behavior</strong><br>
The test should pass.</p>
<p dir="auto"><strong>Environment:</strong></p>
<ul dir="auto">
<li>Axios Version: 0.19.1</li>
<li>OS: Ubuntu 19.10</li>
<li>Browser: n/a</li>
<li>Browser Version: n/a</li>
<li>Additional Library Versions: nock 11.7.2</li>
</ul>
<p dir="auto"><strong>Additional context/Screenshots</strong><br>
Jest error with stack trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" FAIL  src/http.test.js
  ✕ makes HTTP requests (34ms)

  ● makes HTTP requests

    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 invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:193:27)
      at XMLHttpRequestEventTargetImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:119:9)
      at XMLHttpRequestEventTargetImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
      at XMLHttpRequest.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:157:21)
      at requestErrorSteps (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:132:7)
      at dispatchError (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:62:3)
      at Object.validCORSHeaders (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:77:5)
      at receiveResponse (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:847:21)
      at Request.&lt;anonymous&gt; (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:679:38)
      at Request.onRequestResponse (node_modules/request/request.js:1066:10)
      at respond (node_modules/nock/lib/playback_interceptor.js:299:11)
      at respondUsingInterceptor (node_modules/nock/lib/playback_interceptor.js:341:7)
      at node_modules/nock/lib/playback_interceptor.js:281:7

  console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
    Error: Cross origin http://localhost forbidden
        at dispatchError (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:65:19)
        at Object.validCORSHeaders (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:77:5)
        at receiveResponse (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:847:21)
        at Request.&lt;anonymous&gt; (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:679:38)
        at Request.emit (events.js:321:20)
        at Request.onRequestResponse (/home/user/my-app/node_modules/request/request.js:1066:10)
        at OverriddenClientRequest.emit (events.js:321:20)
        at respond (/home/user/my-app/node_modules/nock/lib/playback_interceptor.js:299:11)
        at respondUsingInterceptor (/home/user/my-app/node_modules/nock/lib/playback_interceptor.js:341:7)
        at /home/user/my-app/node_modules/nock/lib/playback_interceptor.js:281:7 undefined"><pre lang="text" class="notranslate"><code class="notranslate"> FAIL  src/http.test.js
  ✕ makes HTTP requests (34ms)

  ● makes HTTP requests

    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 invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:193:27)
      at XMLHttpRequestEventTargetImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:119:9)
      at XMLHttpRequestEventTargetImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
      at XMLHttpRequest.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:157:21)
      at requestErrorSteps (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:132:7)
      at dispatchError (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:62:3)
      at Object.validCORSHeaders (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:77:5)
      at receiveResponse (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:847:21)
      at Request.&lt;anonymous&gt; (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:679:38)
      at Request.onRequestResponse (node_modules/request/request.js:1066:10)
      at respond (node_modules/nock/lib/playback_interceptor.js:299:11)
      at respondUsingInterceptor (node_modules/nock/lib/playback_interceptor.js:341:7)
      at node_modules/nock/lib/playback_interceptor.js:281:7

  console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
    Error: Cross origin http://localhost forbidden
        at dispatchError (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:65:19)
        at Object.validCORSHeaders (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:77:5)
        at receiveResponse (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:847:21)
        at Request.&lt;anonymous&gt; (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:679:38)
        at Request.emit (events.js:321:20)
        at Request.onRequestResponse (/home/user/my-app/node_modules/request/request.js:1066:10)
        at OverriddenClientRequest.emit (events.js:321:20)
        at respond (/home/user/my-app/node_modules/nock/lib/playback_interceptor.js:299:11)
        at respondUsingInterceptor (/home/user/my-app/node_modules/nock/lib/playback_interceptor.js:341:7)
        at /home/user/my-app/node_modules/nock/lib/playback_interceptor.js:281:7 undefined
</code></pre></div>
<p dir="auto">TLDR：</p>
<blockquote>
<p dir="auto">Oh, yeah I don't think we will ever export that.</p>
</blockquote>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1396970789" data-permission-text="Title is private" data-url="https://github.com/axios/axios/issues/5000" data-hovercard-type="issue" data-hovercard-url="/axios/axios/issues/5000/hovercard?comment_id=1311350960&amp;comment_type=issue_comment" href="https://github.com/axios/axios/issues/5000#issuecomment-1311350960">#5000 (comment)</a></p>

<h4 dir="auto">Is your feature request related to a problem? Please describe.</h4>
<p dir="auto">Yes. I'm writing a adaptor to be used in userscript like tampermonkey or Violentmonkey,<br>
it use a xhr provided be broser extension <code class="notranslate">GM.xmlHttpRequest</code> to make cors request.</p>
<p dir="auto">And to make it behavior like axios' xhr adaptor, I'm using some axios' helper functions directly by</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import buildFullPath from &quot;axios/lib/core/buildFullPath&quot;;
import settle from &quot;axios/lib/core/settle&quot;;
import buildURL from &quot;axios/lib/helpers/buildURL&quot;;
import parseHeaders from &quot;axios/lib/helpers/parseHeaders&quot;;
import utils from &quot;axios/lib/utils&quot;;"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">buildFullPath</span> <span class="pl-k">from</span> <span class="pl-s">"axios/lib/core/buildFullPath"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s1">settle</span> <span class="pl-k">from</span> <span class="pl-s">"axios/lib/core/settle"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s1">buildURL</span> <span class="pl-k">from</span> <span class="pl-s">"axios/lib/helpers/buildURL"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s1">parseHeaders</span> <span class="pl-k">from</span> <span class="pl-s">"axios/lib/helpers/parseHeaders"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s1">utils</span> <span class="pl-k">from</span> <span class="pl-s">"axios/lib/utils"</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">But after axios <strong>1.0.0</strong> is released, a <code class="notranslate">exports</code> field is added to package.json, and lib directory is no longer exported anymore, this make me unable to use helper function provided by axios anymore.</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/484aa4fe6addccbd32206a31eb3d2d000843066e/package.json#L6-L17">axios/package.json</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 6 to 17
      in
      <a data-pjax="true" class="commit-tease-sha" href="/axios/axios/commit/484aa4fe6addccbd32206a31eb3d2d000843066e">484aa4f</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="L6" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="6"></td>
          <td id="LC6" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-ent">"exports"</span>: { </td>
        </tr>

        <tr class="border-0">
          <td id="L7" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="7"></td>
          <td id="LC7" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-ent">"."</span>: { </td>
        </tr>

        <tr class="border-0">
          <td id="L8" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="8"></td>
          <td id="LC8" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-ent">"browser"</span>: { </td>
        </tr>

        <tr class="border-0">
          <td id="L9" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="9"></td>
          <td id="LC9" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">       <span class="pl-ent">"require"</span>: <span class="pl-s"><span class="pl-pds">"</span>./index.js<span class="pl-pds">"</span></span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L10" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="10"></td>
          <td id="LC10" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">       <span class="pl-ent">"default"</span>: <span class="pl-s"><span class="pl-pds">"</span>./index.js<span class="pl-pds">"</span></span> </td>
        </tr>

        <tr class="border-0">
          <td id="L11" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="11"></td>
          <td id="LC11" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     }, </td>
        </tr>

        <tr class="border-0">
          <td id="L12" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="12"></td>
          <td id="LC12" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-ent">"default"</span>: { </td>
        </tr>

        <tr class="border-0">
          <td id="L13" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="13"></td>
          <td id="LC13" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">       <span class="pl-ent">"require"</span>: <span class="pl-s"><span class="pl-pds">"</span>./dist/node/axios.cjs<span class="pl-pds">"</span></span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L14" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="14"></td>
          <td id="LC14" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">       <span class="pl-ent">"default"</span>: <span class="pl-s"><span class="pl-pds">"</span>./index.js<span class="pl-pds">"</span></span> </td>
        </tr>

        <tr class="border-0">
          <td id="L15" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="15"></td>
          <td id="LC15" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     } </td>
        </tr>

        <tr class="border-0">
          <td id="L16" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="16"></td>
          <td id="LC16" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   } </td>
        </tr>

        <tr class="border-0">
          <td id="L17" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="17"></td>
          <td id="LC17" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> }, </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">modern js bundler will raise a error for this: <code class="notranslate">Package subpath './lib/core/buildFullPath' is not defined by "exports" in .../node_modules/axios/package.json</code> by bundler.</p>
<h4 dir="auto">Describe the solution you'd like</h4>
<p dir="auto">add <code class="notranslate">lib</code> dir to <code class="notranslate">package.json#exports</code></p>