Google App Script Web App GET and POST request blocked by CORS policy

Show Details

Solution 1: [1]

Although I'm not sure about your Google Apps Script of Web Apps from your question, how about this modification?

Modification points:

  1. I think that your Web Apps might return no values. You can put return ContentService.createTextOutput() in the functions of doPost() and doGet(). By this, at Google Apps Script, the status 200 is returned.

    function doPost(e) { // or doGet(e)
      // do something
      return ContentService.createTextOutput(); // Please add this.
  2. You can modify the client-side script as follows:

    fetch("", {
        method: 'POST',
        body: data,
        headers: {
            'Content-Type': 'text/plain;charset=utf-8',
    }).then(response => {
        console.log("success:", response);
    }).catch(err => {
        console.log("Error:" + err);


  • When you modified the Google Apps Script of Web Apps, please deploy the Web Apps as new version. By this, the latest script is reflected to Web Apps. Please be careful this.


If I misunderstood your question and this was not the result you want, I apologize.

Solution 2: [2]

I have to change access from only me to Anyone.

Solution 3: [3]

Only the following works for me:

In Google Apps Script

function doPost(e) {
  return ContentService.createTextOutput(JSON.stringify({status: "success"})).setMimeType(ContentService.MimeType.JSON);

In JavaScript

fetch(URL, {
      redirect: "follow",
      method: "POST",
      body: JSON.stringify(DATA),
      headers: {
        "Content-Type": "text/plain;charset=utf-8",


This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Credit
Solution 1 Tanaike
Solution 2 Sanskar Tiwari
Solution 3 Hari Das