Question

CORS policy problem in WordPress

  • 16 May 2023
  • 2 replies
  • 1009 views

I have created a test with JavaScript on my Wordpress website. I want to send the user's name and email along with their scores to a Google Sheets spreadsheet, and I'm doing it using the Zapier webhook.
After setting up the JSON and fetch correctly, the console gives me the following error:
Access to fetch at 'https://hooks.zapier.com/hooks/catch/-----------/' from origin 'https://magistral.com' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

Zapier detects the sending of the test, but does not collect the data.

I don't know how to fix it. I attach screenshots of the code and the error.

 


2 replies

Thank you so much, it worked perfectly!

Userlevel 1
Badge +1

Hi @Ignacio Magistral,


I am assuming you are simply wanting to send data to your Zapier webhook for processing and are not interested in the response being returned back by Zapier.

 

As such, could you try adding the "no-cors" option to your fetch and seeing if the problem still persists. (using “no-cors” will not allow you to access the response returned by Zapier) 
 
Your "fetch" statement will end up looking something like this.
 
fetch(url, {
    method: "POST", 
    mode: "no-cors", 
});

Reply