Unable to connect with a google backend from Wix

I have built an ML backend and deployed it over google cloud. When I call the backend from a wix front-end form with some data, I get the following error:


export function button1_click(event) {
// This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
// Add your code for this event here:
var data = $w( “#textBox1” ).value;

var raw = JSON.stringify({ “data” :data});
var requestOptions = {
method: ‘POST’ ,
body: raw,
redirect: ‘follow’
};
var url = “https://url-for-google-webapp
fetch(url, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
. catch (error => console.log( ‘error’ , error));
}

Could it be that you are missing the headers, like:


const headers = {
 "Content-type": "application/json"
    };


and then

var requestOptions = {         
	method: 'POST',
        headers: headers,
        body:  raw,         
	redirect: 'follow' 
        };