title: Axios Request: Blocked by CORS Policy
body: <p>In laravel 5.8, <code>/ "vue": "^2.5.17" / "axios": "^0.18"</code>, I need to read external data which are read from postman ok :
  <a href="https://imgur.com/a/SRBmK0P" rel="nofollow noreferrer">https://imgur.com/a/SRBmK0P</a></p>
  
  <p>I try to read these data using axios and got error:
  <a href="https://imgur.com/a/o97xLm7" rel="nofollow noreferrer">https://imgur.com/a/o97xLm7</a></p>
  
  <p>In the browse, I see details of the request :
  <a href="https://imgur.com/a/EUkyV43" rel="nofollow noreferrer">https://imgur.com/a/EUkyV43</a></p>
  
  <p>My JS code: </p>
  
  <pre><code>            axios.post(window.REMOTE_SEARCH_WEB, {
                  "query": "pc gamers",
                  "blogger": false,
                  "company": false,
                  "influencer": false,
                  "article": false,
                  "pageId": 1,
                  "sort": null,
                  "sortOrder": null,
                  "searchType": 1,
                  "Access-Control-Allow-Origin": this.app_url,
                  "Access-Control-Allow-Methods": "POST",
                  "Access-Control-Max-Age": 86400,
                  "Access-Control-Allow-Headers": "Content-Type, Authorization",
                  'Access-Control-Allow-Credentials': 'true'
              }).then((response) =&gt; {
  </code></pre>
  
  <p>where <code>this.app_url</code> is home <code>url</code> of the site the app run at.</p>
  
  <p>Googling I found several parameters<code>Access-Control-*</code> must be filled, like in code above, but that did not help me.</p>
  
  <p>Can you say how I to fix it?</p>
  
  <p>Can it be that a decision could be from my js code with axios to run action in my control and from there to make request using PHP/Laravel? If yes, please provide example of such decision...</p>
  
  <p><strong>MODIFIED BLOCK :</strong> 
  I installed <a href="https://github.com/barryvdh/laravel-cors" rel="nofollow noreferrer">https://github.com/barryvdh/laravel-cors</a> package and </p>
  
  <p>1) in file I added line in app/Http/Kernel.php</p>
  
  <pre><code>protected $middleware = [
      // ...
      \Barryvdh\Cors\HandleCors::class,
  ];
  </code></pre>
  
  <p>I added in middleware group I that is is not ‘/api’ internal, but external request.
  Is it correct?</p>
  
  <p>2) I left file config/cors.php without changes :
  
  
  <pre><code>return [
  
      'supportsCredentials' =&gt; false,
      'allowedOrigins' =&gt; ['*'],
      'allowedOriginsPatterns' =&gt; [],
      'allowedHeaders' =&gt; ['*'],
      'allowedMethods' =&gt; ['*'],
      'exposedHeaders' =&gt; [],
      'maxAge' =&gt; 0,
  
  ];
  </code></pre>
  
  <p>3) In axios.post request I removed all Access-Control parameters</p>
  
  <pre><code>axios.post(window.REMOTE_SEARCH_WEB, {
      "query": "pc gamers",
      "blogger": false,
      "company": false,
      "influencer": false,
      "article": false,
      "pageId": 1,
      "sort": null,
      "sortOrder": null,
      "searchType": 1,
  }).then((response) =&gt; {
  </code></pre>
  
  <p>4) But the same error in request : <a href="https://imgur.com/a/wbgmrps" rel="nofollow noreferrer">https://imgur.com/a/wbgmrps</a></p>
  
  <p>What is wrong ?</p>
  
  <p>Thanks!</p>