title: how to fix 'Access to XMLHttpRequest has been blocked by CORS policy' Redirect is not allowed for a preflight request only one route
body: <p><a href="https://i.stack.imgur.com/8BpwB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8BpwB.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/FAz9Q.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FAz9Q.png" alt="enter image description here"></a>i'm setting a laravel and vuejs.</p>
  
  <p>CORS plugin for laravel and frontend side i use Axios to call REST api</p>
  
  <p>i got this ERROR
   Access to XMLHttpRequest at '<a href="https://xx.xxxx.xx" rel="noreferrer">https://xx.xxxx.xx</a>' from origin 
   '<a href="http://localhost:8080" rel="noreferrer">http://localhost:8080</a>' has been blocked by CORS policy: Response to preflight 
   request doesn't pass access control check: Redirect is not allowed for a 
   preflight request. </p>
  
  <pre><code>this is for a vuejs axios setup  **main.js**
  axios.defaults.baseURL = process.env.BASE_URL;
  axios.defaults.headers.get['Accepts'] = 'application/json';
  axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
  axios.defaults.headers.common['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept';
  
    **content.vue file**
  
    this.loading = true;
        var companyId = this.$route.params.cid;
        var userId = this.$route.params.uid;
        const thisVue = this;
        var formData = new FormData();
  
    let data = {};
  
    formData.append("subject", this.title);
    formData.append("content", this.content);
    formData.append("posting_article_url", this.blog_link);
    formData.append("recruitment_tension", this.sel_recruitment_tension);
    formData.append("why_hire_engineer", this.sel_company_hire_engineer);
    formData.append("technique_skill", this.requiredTechniqueSkill);
    formData.append("better_technique_skill",this.betterTechniqueSkillIfThereIs);
    formData.append("personality", this.requiredPersonality);
    formData.append("any_request", this.anyRequest);
    formData.append("location", this.location);
    formData.append("supplement_time", this.supplement_time);
    formData.append("supplement_contract", this.supplement_contract);
    formData.append("en_benefits", this.en_benefits);
    formData.append("recruit_role", this.recruit_role);
    formData.append("how_to_proceed", this.how_to_proceed);
    formData.append("current_structure", this.current_structure);
    if (this.selectedSkill.length &gt; 0)
    {
      let selectedSkills = this.selectedSkill
      .filter(obj =&gt; {
        return  obj.id;
      })
      .map(item =&gt; {
        return item.id;
      });
      formData.append("skill_keyword", selectedSkills);
    }
    if (this.imageBlob != "") {
      formData.append("image", this.imageBlob, "temp.png");
    }
    for (var i = 0; i &lt; this.sel_schedule.length; i++) {
      formData.append("freelance_type[" + i + "]", this.sel_schedule[i])
    }
    for (var i = 0; i &lt; this.sel_type_of_contract.length; i++) {
      formData.append("contract_type[" + i + "]", this.sel_type_of_contract[i])
    }
      this.loading = false;
      $('html, body').animate({scrollTop:300}, 'slow');
    } else {
       axios
      .post(
        "/xx/xxx/?token=" + localStorage.getItem("token"),
        formData,
        {
          headers: [
              { "X-localization": localStorage.getItem("lan") },
              { "Access-Control-Allow-Origin": '*' },
              { "Access-Control-Allow-Headers": 'Origin, X-Requested-With, Content-Type, Accept '},
              { "Access-Control-Allow-Methods": "POST, GET, PUT, OPTIONS, DELETE" },
              { "Access-Control-Max-Age": 3600 }
            ]
        }
      )
      .then(res =&gt; {
        if (!res.data.result) {
           if (res.data[0]) {
            this.$toaster.error(res.data[0]);
            this.$store.dispatch("logout");
          }
          if (res.data.errors) {
              for (var i = 0; i &lt; res.data.errors.length; i++) {
                this.$toaster.error(res.data.errors[i].message);
              }
          }
          this.loading = false;
        } else {
          this.$toaster.success(thisVue.$t("success_recruit_add"));
        }
      })
      .catch(() =&gt; {
        this.$toaster.error(thisVue.$t("err_network"));
      });
    }
  </code></pre>
  
  <p>the error occur only one route rest all are working.
  also working on <strong>Postman</strong> </p>