title: How to Solve CORS error in accessing laravel routes
body: <p>Im very new to laravel applications.What im trying to do is developing an outlook web addon that uses the API written in laravel . The problem here is ,it produces the CORS error while accessing API's through outlook mail.</p>
  <p>Error :</p>
  <pre><code>Access to XMLHttpRequest at 'https://test.com/api/test' from origin 'https://localhost:44377' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
  </code></pre>
  <p>What i have tried so far :</p>
  <ul>
  <li>spatia/laravel-cors module installed and tried</li>
  <li>Added this in bootstrap/app.php:</li>
  </ul>
  <pre><code>header('Access-Control-Allow-Origin: *');
  header('Access-Control-Allow-Methods: *');
  header('Access-Control-Allow-Headers: *');
  </code></pre>
  <ul>
  <li>created CORS class file and added as middleware</li>
  </ul>
  <p>And finally end up with the same error.What should I do ?</p>
  <p>Edit :</p>
  <p>Why it automatically redirect the request to https instead of http .Where it went wrong ? The request url should be <a href="http://test.com/api/test" rel="nofollow noreferrer">http://test.com/api/test</a> ,not <a href="https://test.com/api/test" rel="nofollow noreferrer">https://test.com/api/test</a></p>
  <p>Thanks in advance !</p>