title: Vue + Laravel + tinymce upload image blocked by CORS policy
body: <p>I want to upload images insinde the TinyMCE editor but i has been blocked by CORS policy. 
  I had setting the CORS on my Laravel project. Other function is OK to get the data from this Laravel project</p>
  
  <p>These are my Javascript settings:</p>
  
  <pre><code>uploadImg(blobInfo, success, failure) {
        let formData = new FormData();
        formData.append("file", blobInfo.blob(), blobInfo.filename());
        this.axios({
          method: "post",
          url: "/test2",
          headers: {
            "Content-Type": "multipart/form-data"
          },
          withCredentials: false,
          data: formData
        }).then(res =&gt; {
          console.log(res.data);
        });
      }
  </code></pre>
  
  <p>These are my CORS settings:</p>
  
  <pre><code>public function handle(Request $request, \Closure $next)
      {
          $this-&gt;headers = [
              'Access-Control-Allow-Methods' =&gt; 'GET, POST, PUT, DELETE',
              'Access-Control-Allow-Headers' =&gt; $request-&gt;header('Access-Control-Request-Headers'),
              'Access-Control-Allow-Credentials' =&gt; 'true',
              'Access-Control-Max-Age' =&gt; 1728000 
          ];
  
          $this-&gt;allow_origin = [
              'http://localhost',
              'http://localhost:8080',
              'http://localhost:8000',
          ];
  
  
          $origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';
  
          if (!in_array($origin, $this-&gt;allow_origin) &amp;&amp; !empty($origin)){
              return new Response('Forbidden', 403);
          }
  
  
          if ($request-&gt;isMethod('options'))
              return $this-&gt;setCorsHeaders(new Response('OK', 200), $origin);
  
          $response = $next($request);
          $methodVariable = array($response, 'header');
  
          if (is_callable($methodVariable, false, $callable_name)) {
              return $this-&gt;setCorsHeaders($response, $origin);
          }
          return $response;
      }
  
      /**
       * @param $response
       * @return mixed
       */
      public function setCorsHeaders($response, $origin)
      {
          foreach ($this-&gt;headers as $key =&gt; $value) {
              $response-&gt;header($key, $value);
          }
          if (in_array($origin, $this-&gt;allow_origin)) {
              $response-&gt;header('Access-Control-Allow-Origin', $origin);
          } else {
              $response-&gt;header('Access-Control-Allow-Origin', '');
          }
          return $response;
      }
  </code></pre>
  
  <p>this is the error message:
  <a href="https://i.stack.imgur.com/JNiLK.png" rel="nofollow noreferrer">error message</a></p>
  
  <p>Can anyone tell me where did i make a mistake? Thanks </p>