<p dir="auto">Hi All,</p>
<p dir="auto">I've got lambda function which I access via API Gateway.<br>
This function works ok when I test it via Postman or via this test which uses <code class="notranslate">request</code> library:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="it('shoudl work via request', async () =&gt; {
        
        var options = { method: 'POST',
        url: 'https://-----------.execute-api.eu-central-1.amazonaws.com/dev/generate',
        headers: 
         { 
           'Cache-Control': 'no-cache',
           'Content-Type': 'application/json' },
        body: 
         { html: 'PGgxPkhlbGxvIHt7bmFtZX19PC9oMT48aDI+SGVsbG8gd29ybGQhISE8L2gyPg==',
           variables: 'eyJuYW1lIjoiV29ybGQiLCJwYXRoIjoiL2hvbWUvcGF3ZWwvLm52bS92ZXJzaW9ucy9ub2RlL3Y4LjExLjMvYmluOi91c3IvbG9jYWwvc2JpbjovdXNyL2xvY2FsL2JpbjovdXNyL3NiaW46L3Vzci9iaW46L3NiaW46L2JpbjovdXNyL2dhbWVzOi91c3IvbG9jYWwvZ2FtZXM6L3NuYXAvYmluOi91c3IvbGliL2p2bS9qYXZhLTgtb3JhY2xlL2JpbjovdXNyL2xpYi9qdm0vamF2YS04LW9yYWNsZS9kYi9iaW46L3Vzci9saWIvanZtL2phdmEtOC1vcmFjbGUvanJlL2JpbjovdmFyL3Rhc2sifQ==',
           css: 'aDEge2NvbG9yOiByZWR9' },
        json: true };
      
      request(options, function (error, response, body) {
        if (error) throw new Error(error);
        expect(body.generated).toBeTruthy()
        expect(body.pdf).toBeTruthy()
      });
    })"><pre class="notranslate"><code class="notranslate">it('shoudl work via request', async () =&gt; {
        
        var options = { method: 'POST',
        url: 'https://-----------.execute-api.eu-central-1.amazonaws.com/dev/generate',
        headers: 
         { 
           'Cache-Control': 'no-cache',
           'Content-Type': 'application/json' },
        body: 
         { html: 'PGgxPkhlbGxvIHt7bmFtZX19PC9oMT48aDI+SGVsbG8gd29ybGQhISE8L2gyPg==',
           variables: 'eyJuYW1lIjoiV29ybGQiLCJwYXRoIjoiL2hvbWUvcGF3ZWwvLm52bS92ZXJzaW9ucy9ub2RlL3Y4LjExLjMvYmluOi91c3IvbG9jYWwvc2JpbjovdXNyL2xvY2FsL2JpbjovdXNyL3NiaW46L3Vzci9iaW46L3NiaW46L2JpbjovdXNyL2dhbWVzOi91c3IvbG9jYWwvZ2FtZXM6L3NuYXAvYmluOi91c3IvbGliL2p2bS9qYXZhLTgtb3JhY2xlL2JpbjovdXNyL2xpYi9qdm0vamF2YS04LW9yYWNsZS9kYi9iaW46L3Vzci9saWIvanZtL2phdmEtOC1vcmFjbGUvanJlL2JpbjovdmFyL3Rhc2sifQ==',
           css: 'aDEge2NvbG9yOiByZWR9' },
        json: true };
      
      request(options, function (error, response, body) {
        if (error) throw new Error(error);
        expect(body.generated).toBeTruthy()
        expect(body.pdf).toBeTruthy()
      });
    })
</code></pre></div>
<h3 dir="auto">Problem</h3>
<p dir="auto">Unfortunately, when I'm using Axis I get following message <strong>Error: Cross origin <a href="http://localhost" rel="nofollow">http://localhost</a> forbidden</strong>.</p>
<p dir="auto">Could you please tell me what am I doing wrong?</p>
<p dir="auto">My code looks like that:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="   it('should work via axios', async () =&gt; {
        const event = {
            html: &quot;PGgxPkhlbGxvIHt7bmFtZX19PC9oMT48aDI+SGVsbG8gd29ybGQhISE8L2gyPg==&quot;,
            variables: &quot;eyJuYW1lIjoiV29ybGQiLCJwYXRoIjoiL2hvbWUvcGF3ZWwvLm52bS92ZXJzaW9ucy9ub2RlL3Y4LjExLjMvYmluOi91c3IvbG9jYWwvc2JpbjovdXNyL2xvY2FsL2JpbjovdXNyL3NiaW46L3Vzci9iaW46L3NiaW46L2JpbjovdXNyL2dhbWVzOi91c3IvbG9jYWwvZ2FtZXM6L3NuYXAvYmluOi91c3IvbGliL2p2bS9qYXZhLTgtb3JhY2xlL2JpbjovdXNyL2xpYi9qdm0vamF2YS04LW9yYWNsZS9kYi9iaW46L3Vzci9saWIvanZtL2phdmEtOC1vcmFjbGUvanJlL2JpbjovdmFyL3Rhc2sifQ==&quot;,
            css: &quot;aDEge2NvbG9yOiByZWR9&quot;
        }

        await axios.post(url, event, {
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json',
                },
                responseType: 'json',
                withCredentials: true,
            })
            .then(function (response) {
                console.log(response);
                // console.log('ok')
                expect(response.generated).toBeTruthy()
                expect(response.pdf).toBeTruthy()
            })
            .catch(function (error) {
                console.log(error);
            });
    })"><pre class="notranslate"><code class="notranslate">   it('should work via axios', async () =&gt; {
        const event = {
            html: "PGgxPkhlbGxvIHt7bmFtZX19PC9oMT48aDI+SGVsbG8gd29ybGQhISE8L2gyPg==",
            variables: "eyJuYW1lIjoiV29ybGQiLCJwYXRoIjoiL2hvbWUvcGF3ZWwvLm52bS92ZXJzaW9ucy9ub2RlL3Y4LjExLjMvYmluOi91c3IvbG9jYWwvc2JpbjovdXNyL2xvY2FsL2JpbjovdXNyL3NiaW46L3Vzci9iaW46L3NiaW46L2JpbjovdXNyL2dhbWVzOi91c3IvbG9jYWwvZ2FtZXM6L3NuYXAvYmluOi91c3IvbGliL2p2bS9qYXZhLTgtb3JhY2xlL2JpbjovdXNyL2xpYi9qdm0vamF2YS04LW9yYWNsZS9kYi9iaW46L3Vzci9saWIvanZtL2phdmEtOC1vcmFjbGUvanJlL2JpbjovdmFyL3Rhc2sifQ==",
            css: "aDEge2NvbG9yOiByZWR9"
        }

        await axios.post(url, event, {
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json',
                },
                responseType: 'json',
                withCredentials: true,
            })
            .then(function (response) {
                console.log(response);
                // console.log('ok')
                expect(response.generated).toBeTruthy()
                expect(response.pdf).toBeTruthy()
            })
            .catch(function (error) {
                console.log(error);
            });
    })
</code></pre></div>
<h3 dir="auto">Context</h3>
<ul dir="auto">
<li>axios version: v0.18.0</li>
<li>Environment: node v8.11.3</li>
</ul>
<h4 dir="auto">Summary</h4>
<p dir="auto">I have noticed that npm package includes the <code class="notranslate">dist</code> folder which contains both minified and full versions of axios. At the same time, the npm package itself is only using the <code class="notranslate">lib</code> folder. Is there a reason to ship pre-built versions via npm in addition to the library itself?  The duplication adds around 200KB and requires a workaround when packaging axios for the AWS Lambda.</p>
<h4 dir="auto">Context</h4>
<ul dir="auto">
<li>axios version: latest</li>
</ul>